Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f6f9add69 | ||
|
|
ab7f3a1ca8 |
33
README.md
33
README.md
@@ -15,6 +15,39 @@ Preview versions are intentionally excluded. For example: `v2-beta`
|
|||||||
|
|
||||||
Optional args may be supplied to control which refs are included. See `script/add-action.sh --help` for more info.
|
Optional args may be supplied to control which refs are included. See `script/add-action.sh --help` for more info.
|
||||||
|
|
||||||
|
### Ignoring old versions
|
||||||
|
|
||||||
|
To exclude certain old version tags from being packaged, add an `ignoreTags` array to the action config JSON file. Each entry is a regex pattern that will be tested against tag names.
|
||||||
|
|
||||||
|
**When adding a new action**, use the `--ignore-tags` option with simple version prefixes:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./script/add-action.sh --ignore-tags "v1,v2" actions/checkout
|
||||||
|
```
|
||||||
|
|
||||||
|
This will automatically generate regex patterns that match `v1`, `v1.x`, `v2`, `v2.x`, etc.
|
||||||
|
|
||||||
|
**For existing actions**, use the helper script to add ignore tags:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./script/add-ignore-tags.sh --ignore-tags "v1,v2" actions/checkout
|
||||||
|
```
|
||||||
|
|
||||||
|
Or add `ignoreTags` directly to the JSON config file:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"owner": "actions",
|
||||||
|
"repo": "checkout",
|
||||||
|
"ignoreTags": [
|
||||||
|
"^v1(\\..*)?$",
|
||||||
|
"^v2(\\..*)?$"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Tags matching any of the patterns will be excluded from the generated scripts while remaining in the config for historical reference. The `ignoreTags` field is preserved when running `update-action.sh`.
|
||||||
|
|
||||||
### How to use this in the self-hosted runner?
|
### How to use this in the self-hosted runner?
|
||||||
|
|
||||||
Please read the doc @kenmuse has put together at: https://www.kenmuse.com/blog/building-github-actions-runner-images-with-an-action-archive-cache/
|
Please read the doc @kenmuse has put together at: https://www.kenmuse.com/blog/building-github-actions-runner-images-with-an-action-archive-cache/
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"+^v[3-9]+(\\.[0-9]+){0,2}$"
|
"+^v[3-9]+(\\.[0-9]+){0,2}$"
|
||||||
],
|
],
|
||||||
"branches": {
|
"branches": {
|
||||||
"main": "0057852bfaa89a56745cba8c7296529d2fc39830"
|
"main": "9255dc7a253b0ccc959486e2bca901246202afeb"
|
||||||
},
|
},
|
||||||
"defaultBranch": "main",
|
"defaultBranch": "main",
|
||||||
"tags": {
|
"tags": {
|
||||||
@@ -135,6 +135,15 @@
|
|||||||
},
|
},
|
||||||
"v4.3.0": {
|
"v4.3.0": {
|
||||||
"commit": "0057852bfaa89a56745cba8c7296529d2fc39830"
|
"commit": "0057852bfaa89a56745cba8c7296529d2fc39830"
|
||||||
|
},
|
||||||
|
"v5": {
|
||||||
|
"commit": "9255dc7a253b0ccc959486e2bca901246202afeb"
|
||||||
|
},
|
||||||
|
"v5.0.0": {
|
||||||
|
"commit": "a7833574556fa59680c1b7cb190c1735db73ebf0"
|
||||||
|
},
|
||||||
|
"v5.0.1": {
|
||||||
|
"commit": "9255dc7a253b0ccc959486e2bca901246202afeb"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
"+^v[0-9]+(\\.[0-9]+){0,2}$"
|
"+^v[0-9]+(\\.[0-9]+){0,2}$"
|
||||||
],
|
],
|
||||||
"branches": {
|
"branches": {
|
||||||
"main": "395ad3262231945c25e8478fd5baf05154b1d79f"
|
"main": "65d868f8d4d85d7d4abb7de0875cde3fcc8798f5"
|
||||||
},
|
},
|
||||||
"defaultBranch": "main",
|
"defaultBranch": "main",
|
||||||
"tags": {
|
"tags": {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"+^v[0-9]+(\\.[0-9]+){0,2}$"
|
"+^v[0-9]+(\\.[0-9]+){0,2}$"
|
||||||
],
|
],
|
||||||
"branches": {
|
"branches": {
|
||||||
"main": "330a01c490aca151604b8cf639adc76d48f6c5d4"
|
"main": "b7c566a772e6b6bfb58ed0dc250532a479d7789f"
|
||||||
},
|
},
|
||||||
"defaultBranch": "main",
|
"defaultBranch": "main",
|
||||||
"tags": {
|
"tags": {
|
||||||
@@ -146,6 +146,12 @@
|
|||||||
},
|
},
|
||||||
"v5.0.0": {
|
"v5.0.0": {
|
||||||
"commit": "330a01c490aca151604b8cf639adc76d48f6c5d4"
|
"commit": "330a01c490aca151604b8cf639adc76d48f6c5d4"
|
||||||
|
},
|
||||||
|
"v6": {
|
||||||
|
"commit": "b7c566a772e6b6bfb58ed0dc250532a479d7789f"
|
||||||
|
},
|
||||||
|
"v6.0.0": {
|
||||||
|
"commit": "b7c566a772e6b6bfb58ed0dc250532a479d7789f"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
14
script/add-ignore-tags.sh
Executable file
14
script/add-ignore-tags.sh
Executable file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
script_dir="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
|
||||||
|
|
||||||
|
# Minimum node version
|
||||||
|
$script_dir/internal/check-node.sh
|
||||||
|
|
||||||
|
# Add ignore tags to the action
|
||||||
|
node "$script_dir/internal/add-ignore-tags.js" $*
|
||||||
|
|
||||||
|
# Regenerate action scripts
|
||||||
|
$script_dir/internal/generate-scripts.sh
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
mkdir actions_cache
|
mkdir actions_cache
|
||||||
pushd actions_cache
|
pushd actions_cache
|
||||||
curl -s -S -L -o '0057852bfaa89a56745cba8c7296529d2fc39830.tar.gz' 'https://api.github.com/repos/actions/cache/tarball/0057852bfaa89a56745cba8c7296529d2fc39830'
|
curl -s -S -L -o '9255dc7a253b0ccc959486e2bca901246202afeb.tar.gz' 'https://api.github.com/repos/actions/cache/tarball/9255dc7a253b0ccc959486e2bca901246202afeb'
|
||||||
curl -s -S -L -o '0057852bfaa89a56745cba8c7296529d2fc39830.zip' 'https://api.github.com/repos/actions/cache/zipball/0057852bfaa89a56745cba8c7296529d2fc39830'
|
curl -s -S -L -o '9255dc7a253b0ccc959486e2bca901246202afeb.zip' 'https://api.github.com/repos/actions/cache/zipball/9255dc7a253b0ccc959486e2bca901246202afeb'
|
||||||
curl -s -S -L -o '6f8efc29b200d32929f49075959781ed54ec270c.tar.gz' 'https://api.github.com/repos/actions/cache/tarball/6f8efc29b200d32929f49075959781ed54ec270c'
|
curl -s -S -L -o '6f8efc29b200d32929f49075959781ed54ec270c.tar.gz' 'https://api.github.com/repos/actions/cache/tarball/6f8efc29b200d32929f49075959781ed54ec270c'
|
||||||
curl -s -S -L -o '6f8efc29b200d32929f49075959781ed54ec270c.zip' 'https://api.github.com/repos/actions/cache/zipball/6f8efc29b200d32929f49075959781ed54ec270c'
|
curl -s -S -L -o '6f8efc29b200d32929f49075959781ed54ec270c.zip' 'https://api.github.com/repos/actions/cache/zipball/6f8efc29b200d32929f49075959781ed54ec270c'
|
||||||
curl -s -S -L -o '4b0cf6cc4619e737324ddfcec08fff2413359514.tar.gz' 'https://api.github.com/repos/actions/cache/tarball/4b0cf6cc4619e737324ddfcec08fff2413359514'
|
curl -s -S -L -o '4b0cf6cc4619e737324ddfcec08fff2413359514.tar.gz' 'https://api.github.com/repos/actions/cache/tarball/4b0cf6cc4619e737324ddfcec08fff2413359514'
|
||||||
@@ -86,4 +86,10 @@ curl -s -S -L -o '0400d5f644dc74513175e3cd8d07132dd4860809.tar.gz' 'https://api.
|
|||||||
curl -s -S -L -o '0400d5f644dc74513175e3cd8d07132dd4860809.zip' 'https://api.github.com/repos/actions/cache/zipball/0400d5f644dc74513175e3cd8d07132dd4860809'
|
curl -s -S -L -o '0400d5f644dc74513175e3cd8d07132dd4860809.zip' 'https://api.github.com/repos/actions/cache/zipball/0400d5f644dc74513175e3cd8d07132dd4860809'
|
||||||
curl -s -S -L -o '0057852bfaa89a56745cba8c7296529d2fc39830.tar.gz' 'https://api.github.com/repos/actions/cache/tarball/0057852bfaa89a56745cba8c7296529d2fc39830'
|
curl -s -S -L -o '0057852bfaa89a56745cba8c7296529d2fc39830.tar.gz' 'https://api.github.com/repos/actions/cache/tarball/0057852bfaa89a56745cba8c7296529d2fc39830'
|
||||||
curl -s -S -L -o '0057852bfaa89a56745cba8c7296529d2fc39830.zip' 'https://api.github.com/repos/actions/cache/zipball/0057852bfaa89a56745cba8c7296529d2fc39830'
|
curl -s -S -L -o '0057852bfaa89a56745cba8c7296529d2fc39830.zip' 'https://api.github.com/repos/actions/cache/zipball/0057852bfaa89a56745cba8c7296529d2fc39830'
|
||||||
|
curl -s -S -L -o '9255dc7a253b0ccc959486e2bca901246202afeb.tar.gz' 'https://api.github.com/repos/actions/cache/tarball/9255dc7a253b0ccc959486e2bca901246202afeb'
|
||||||
|
curl -s -S -L -o '9255dc7a253b0ccc959486e2bca901246202afeb.zip' 'https://api.github.com/repos/actions/cache/zipball/9255dc7a253b0ccc959486e2bca901246202afeb'
|
||||||
|
curl -s -S -L -o 'a7833574556fa59680c1b7cb190c1735db73ebf0.tar.gz' 'https://api.github.com/repos/actions/cache/tarball/a7833574556fa59680c1b7cb190c1735db73ebf0'
|
||||||
|
curl -s -S -L -o 'a7833574556fa59680c1b7cb190c1735db73ebf0.zip' 'https://api.github.com/repos/actions/cache/zipball/a7833574556fa59680c1b7cb190c1735db73ebf0'
|
||||||
|
curl -s -S -L -o '9255dc7a253b0ccc959486e2bca901246202afeb.tar.gz' 'https://api.github.com/repos/actions/cache/tarball/9255dc7a253b0ccc959486e2bca901246202afeb'
|
||||||
|
curl -s -S -L -o '9255dc7a253b0ccc959486e2bca901246202afeb.zip' 'https://api.github.com/repos/actions/cache/zipball/9255dc7a253b0ccc959486e2bca901246202afeb'
|
||||||
popd
|
popd
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
mkdir actions_setup-node
|
mkdir actions_setup-node
|
||||||
pushd actions_setup-node
|
pushd actions_setup-node
|
||||||
curl -s -S -L -o '395ad3262231945c25e8478fd5baf05154b1d79f.tar.gz' 'https://api.github.com/repos/actions/setup-node/tarball/395ad3262231945c25e8478fd5baf05154b1d79f'
|
curl -s -S -L -o '65d868f8d4d85d7d4abb7de0875cde3fcc8798f5.tar.gz' 'https://api.github.com/repos/actions/setup-node/tarball/65d868f8d4d85d7d4abb7de0875cde3fcc8798f5'
|
||||||
curl -s -S -L -o '395ad3262231945c25e8478fd5baf05154b1d79f.zip' 'https://api.github.com/repos/actions/setup-node/zipball/395ad3262231945c25e8478fd5baf05154b1d79f'
|
curl -s -S -L -o '65d868f8d4d85d7d4abb7de0875cde3fcc8798f5.zip' 'https://api.github.com/repos/actions/setup-node/zipball/65d868f8d4d85d7d4abb7de0875cde3fcc8798f5'
|
||||||
curl -s -S -L -o 'f1f314fca9dfce2769ece7d933488f076716723e.tar.gz' 'https://api.github.com/repos/actions/setup-node/tarball/f1f314fca9dfce2769ece7d933488f076716723e'
|
curl -s -S -L -o 'f1f314fca9dfce2769ece7d933488f076716723e.tar.gz' 'https://api.github.com/repos/actions/setup-node/tarball/f1f314fca9dfce2769ece7d933488f076716723e'
|
||||||
curl -s -S -L -o 'f1f314fca9dfce2769ece7d933488f076716723e.zip' 'https://api.github.com/repos/actions/setup-node/zipball/f1f314fca9dfce2769ece7d933488f076716723e'
|
curl -s -S -L -o 'f1f314fca9dfce2769ece7d933488f076716723e.zip' 'https://api.github.com/repos/actions/setup-node/zipball/f1f314fca9dfce2769ece7d933488f076716723e'
|
||||||
curl -s -S -L -o '0d7d2ca66539aca4af6c5102e29a33757e2c2d2c.tar.gz' 'https://api.github.com/repos/actions/setup-node/tarball/0d7d2ca66539aca4af6c5102e29a33757e2c2d2c'
|
curl -s -S -L -o '0d7d2ca66539aca4af6c5102e29a33757e2c2d2c.tar.gz' 'https://api.github.com/repos/actions/setup-node/tarball/0d7d2ca66539aca4af6c5102e29a33757e2c2d2c'
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
mkdir actions_upload-artifact
|
mkdir actions_upload-artifact
|
||||||
pushd actions_upload-artifact
|
pushd actions_upload-artifact
|
||||||
curl -s -S -L -o '330a01c490aca151604b8cf639adc76d48f6c5d4.tar.gz' 'https://api.github.com/repos/actions/upload-artifact/tarball/330a01c490aca151604b8cf639adc76d48f6c5d4'
|
curl -s -S -L -o 'b7c566a772e6b6bfb58ed0dc250532a479d7789f.tar.gz' 'https://api.github.com/repos/actions/upload-artifact/tarball/b7c566a772e6b6bfb58ed0dc250532a479d7789f'
|
||||||
curl -s -S -L -o '330a01c490aca151604b8cf639adc76d48f6c5d4.zip' 'https://api.github.com/repos/actions/upload-artifact/zipball/330a01c490aca151604b8cf639adc76d48f6c5d4'
|
curl -s -S -L -o 'b7c566a772e6b6bfb58ed0dc250532a479d7789f.zip' 'https://api.github.com/repos/actions/upload-artifact/zipball/b7c566a772e6b6bfb58ed0dc250532a479d7789f'
|
||||||
curl -s -S -L -o '3446296876d12d4e3a0f3145a3c87e67bf0a16b5.tar.gz' 'https://api.github.com/repos/actions/upload-artifact/tarball/3446296876d12d4e3a0f3145a3c87e67bf0a16b5'
|
curl -s -S -L -o '3446296876d12d4e3a0f3145a3c87e67bf0a16b5.tar.gz' 'https://api.github.com/repos/actions/upload-artifact/tarball/3446296876d12d4e3a0f3145a3c87e67bf0a16b5'
|
||||||
curl -s -S -L -o '3446296876d12d4e3a0f3145a3c87e67bf0a16b5.zip' 'https://api.github.com/repos/actions/upload-artifact/zipball/3446296876d12d4e3a0f3145a3c87e67bf0a16b5'
|
curl -s -S -L -o '3446296876d12d4e3a0f3145a3c87e67bf0a16b5.zip' 'https://api.github.com/repos/actions/upload-artifact/zipball/3446296876d12d4e3a0f3145a3c87e67bf0a16b5'
|
||||||
curl -s -S -L -o '3446296876d12d4e3a0f3145a3c87e67bf0a16b5.tar.gz' 'https://api.github.com/repos/actions/upload-artifact/tarball/3446296876d12d4e3a0f3145a3c87e67bf0a16b5'
|
curl -s -S -L -o '3446296876d12d4e3a0f3145a3c87e67bf0a16b5.tar.gz' 'https://api.github.com/repos/actions/upload-artifact/tarball/3446296876d12d4e3a0f3145a3c87e67bf0a16b5'
|
||||||
@@ -92,4 +92,8 @@ curl -s -S -L -o '330a01c490aca151604b8cf639adc76d48f6c5d4.tar.gz' 'https://api.
|
|||||||
curl -s -S -L -o '330a01c490aca151604b8cf639adc76d48f6c5d4.zip' 'https://api.github.com/repos/actions/upload-artifact/zipball/330a01c490aca151604b8cf639adc76d48f6c5d4'
|
curl -s -S -L -o '330a01c490aca151604b8cf639adc76d48f6c5d4.zip' 'https://api.github.com/repos/actions/upload-artifact/zipball/330a01c490aca151604b8cf639adc76d48f6c5d4'
|
||||||
curl -s -S -L -o '330a01c490aca151604b8cf639adc76d48f6c5d4.tar.gz' 'https://api.github.com/repos/actions/upload-artifact/tarball/330a01c490aca151604b8cf639adc76d48f6c5d4'
|
curl -s -S -L -o '330a01c490aca151604b8cf639adc76d48f6c5d4.tar.gz' 'https://api.github.com/repos/actions/upload-artifact/tarball/330a01c490aca151604b8cf639adc76d48f6c5d4'
|
||||||
curl -s -S -L -o '330a01c490aca151604b8cf639adc76d48f6c5d4.zip' 'https://api.github.com/repos/actions/upload-artifact/zipball/330a01c490aca151604b8cf639adc76d48f6c5d4'
|
curl -s -S -L -o '330a01c490aca151604b8cf639adc76d48f6c5d4.zip' 'https://api.github.com/repos/actions/upload-artifact/zipball/330a01c490aca151604b8cf639adc76d48f6c5d4'
|
||||||
|
curl -s -S -L -o 'b7c566a772e6b6bfb58ed0dc250532a479d7789f.tar.gz' 'https://api.github.com/repos/actions/upload-artifact/tarball/b7c566a772e6b6bfb58ed0dc250532a479d7789f'
|
||||||
|
curl -s -S -L -o 'b7c566a772e6b6bfb58ed0dc250532a479d7789f.zip' 'https://api.github.com/repos/actions/upload-artifact/zipball/b7c566a772e6b6bfb58ed0dc250532a479d7789f'
|
||||||
|
curl -s -S -L -o 'b7c566a772e6b6bfb58ed0dc250532a479d7789f.tar.gz' 'https://api.github.com/repos/actions/upload-artifact/tarball/b7c566a772e6b6bfb58ed0dc250532a479d7789f'
|
||||||
|
curl -s -S -L -o 'b7c566a772e6b6bfb58ed0dc250532a479d7789f.zip' 'https://api.github.com/repos/actions/upload-artifact/zipball/b7c566a772e6b6bfb58ed0dc250532a479d7789f'
|
||||||
popd
|
popd
|
||||||
|
|||||||
@@ -26,6 +26,12 @@ class ActionConfig {
|
|||||||
*/
|
*/
|
||||||
patterns = []
|
patterns = []
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tag patterns to ignore during packaging
|
||||||
|
* @type {string[]|undefined}
|
||||||
|
*/
|
||||||
|
ignoreTags = undefined
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Branch versions (ref to commit SHA)
|
* Branch versions (ref to commit SHA)
|
||||||
* @type {{[ref: string]: string}}
|
* @type {{[ref: string]: string}}
|
||||||
@@ -63,12 +69,13 @@ exports.TagVersion = TagVersion
|
|||||||
/**
|
/**
|
||||||
* Adds a new action config file
|
* Adds a new action config file
|
||||||
* @param {string} owner
|
* @param {string} owner
|
||||||
* @param {string} repos
|
* @param {string} repo
|
||||||
* @param {string[]} patternStrings
|
* @param {string[]} patternStrings
|
||||||
* @param {string} defaultBranch
|
* @param {string} defaultBranch
|
||||||
|
* @param {string[]|undefined} ignoreTags
|
||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
async function add(owner, repo, patternStrings, defaultBranch) {
|
async function add(owner, repo, patternStrings, defaultBranch, ignoreTags) {
|
||||||
assert.ok(owner, "Arg 'owner' must not be empty")
|
assert.ok(owner, "Arg 'owner' must not be empty")
|
||||||
assert.ok(repo, "Arg 'repo' must not be empty")
|
assert.ok(repo, "Arg 'repo' must not be empty")
|
||||||
assert.ok(patternStrings, "Arg 'patternStrings' must not be null")
|
assert.ok(patternStrings, "Arg 'patternStrings' must not be null")
|
||||||
@@ -84,6 +91,9 @@ async function add(owner, repo, patternStrings, defaultBranch) {
|
|||||||
config.owner = owner
|
config.owner = owner
|
||||||
config.repo = repo
|
config.repo = repo
|
||||||
config.patterns = patternStrings
|
config.patterns = patternStrings
|
||||||
|
if (ignoreTags && ignoreTags.length > 0) {
|
||||||
|
config.ignoreTags = ignoreTags
|
||||||
|
}
|
||||||
config.defaultBranch = defaultBranch
|
config.defaultBranch = defaultBranch
|
||||||
|
|
||||||
const tempDir = path.join(paths.temp, `${owner}_${repo}`)
|
const tempDir = path.join(paths.temp, `${owner}_${repo}`)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ async function main() {
|
|||||||
const repo = args.repo
|
const repo = args.repo
|
||||||
const patterns = args.patterns
|
const patterns = args.patterns
|
||||||
const defaultBranch = args.defaultBranch || 'master'
|
const defaultBranch = args.defaultBranch || 'master'
|
||||||
|
const ignoreTags = args.ignoreTags
|
||||||
|
|
||||||
// File exists?
|
// File exists?
|
||||||
const file = actionConfig.getFilePath(owner, repo)
|
const file = actionConfig.getFilePath(owner, repo)
|
||||||
@@ -23,7 +24,7 @@ async function main() {
|
|||||||
await fsHelper.reinitTemp()
|
await fsHelper.reinitTemp()
|
||||||
|
|
||||||
// Add the config
|
// Add the config
|
||||||
await actionConfig.add(owner, repo, patterns, defaultBranch)
|
await actionConfig.add(owner, repo, patterns, defaultBranch, ignoreTags)
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
// Help
|
// Help
|
||||||
@@ -50,6 +51,7 @@ class Args {
|
|||||||
repo = ''
|
repo = ''
|
||||||
patterns = []
|
patterns = []
|
||||||
defaultBranch = ''
|
defaultBranch = ''
|
||||||
|
ignoreTags = []
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -58,7 +60,7 @@ class Args {
|
|||||||
*/
|
*/
|
||||||
function getArgs() {
|
function getArgs() {
|
||||||
// Parse
|
// Parse
|
||||||
const parsedArgs = argHelper.parse([], ['default-branch'])
|
const parsedArgs = argHelper.parse([], ['default-branch', 'ignore-tags'])
|
||||||
if (parsedArgs.arguments.length < 1) {
|
if (parsedArgs.arguments.length < 1) {
|
||||||
argHelper.throwError('Expected at least one arg')
|
argHelper.throwError('Expected at least one arg')
|
||||||
}
|
}
|
||||||
@@ -81,17 +83,32 @@ function getArgs() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Parse ignore-tags (comma-separated version prefixes like v1,v2)
|
||||||
|
// These are converted to regex patterns that match the version and all its sub-versions
|
||||||
|
let ignoreTags = []
|
||||||
|
if (parsedArgs.options['ignore-tags']) {
|
||||||
|
const prefixes = parsedArgs.options['ignore-tags'].split(',').map(t => t.trim()).filter(t => t)
|
||||||
|
for (const prefix of prefixes) {
|
||||||
|
// Convert simple version prefix like "v1" to regex pattern "^v1(\\..*)?$"
|
||||||
|
// This matches "v1", "v1.0", "v1.0.0", etc.
|
||||||
|
const escapedPrefix = prefix.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
||||||
|
ignoreTags.push(`^${escapedPrefix}(\\..*)?$`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
owner: splitNwo[0],
|
owner: splitNwo[0],
|
||||||
repo: splitNwo[1],
|
repo: splitNwo[1],
|
||||||
patterns: patterns,
|
patterns: patterns,
|
||||||
defaultBranch: parsedArgs.options['default-branch']
|
defaultBranch: parsedArgs.options['default-branch'],
|
||||||
|
ignoreTags: ignoreTags
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function printUsage() {
|
function printUsage() {
|
||||||
console.error('USAGE: add-action.sh [--default-branch branch] nwo [(+|-)regexp [...]]')
|
console.error('USAGE: add-action.sh [--default-branch branch] [--ignore-tags versions] nwo [(+|-)regexp [...]]')
|
||||||
console.error(` --default-branch Default branch name. For example: master`)
|
console.error(` --default-branch Default branch name. For example: master`)
|
||||||
|
console.error(` --ignore-tags Comma-separated version prefixes to ignore. For example: v1,v2`)
|
||||||
console.error(` nwo Name with owner. For example: actions/checkout`)
|
console.error(` nwo Name with owner. For example: actions/checkout`)
|
||||||
console.error(` regexp Refs to include or exclude. Default: ${actionConfig.defaultPatterns.join(' ')}`)
|
console.error(` regexp Refs to include or exclude. Default: ${actionConfig.defaultPatterns.join(' ')}`)
|
||||||
}
|
}
|
||||||
|
|||||||
105
script/internal/add-ignore-tags.js
Normal file
105
script/internal/add-ignore-tags.js
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
const actionConfig = require('./action-config')
|
||||||
|
const argHelper = require('./arg-helper')
|
||||||
|
const debugHelper = require('./debug-helper')
|
||||||
|
const fs = require('fs')
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
try {
|
||||||
|
// Command line args
|
||||||
|
const args = getArgs()
|
||||||
|
|
||||||
|
// Get the action config file
|
||||||
|
const file = actionConfig.getFilePath(args.owner, args.repo)
|
||||||
|
debugHelper.debug(`file: ${file}`)
|
||||||
|
|
||||||
|
// Load the config
|
||||||
|
const config = await actionConfig.loadFromPath(file)
|
||||||
|
|
||||||
|
// Add ignore tags
|
||||||
|
if (!config.ignoreTags) {
|
||||||
|
config.ignoreTags = []
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add new patterns (avoid duplicates)
|
||||||
|
for (const pattern of args.ignoreTags) {
|
||||||
|
if (!config.ignoreTags.includes(pattern)) {
|
||||||
|
config.ignoreTags.push(pattern)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write config back
|
||||||
|
await fs.promises.writeFile(file, JSON.stringify(config, null, ' '))
|
||||||
|
console.log(`Updated config file: ${file}`)
|
||||||
|
console.log(` ignoreTags: ${JSON.stringify(config.ignoreTags)}`)
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
// Help
|
||||||
|
if (err.code === argHelper.helpCode) {
|
||||||
|
printUsage()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Arg error?
|
||||||
|
if (err.code === argHelper.errorCode) {
|
||||||
|
printUsage()
|
||||||
|
console.error('')
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print error
|
||||||
|
debugHelper.debug(err.stack)
|
||||||
|
console.error(`ERROR: ${err.message}`)
|
||||||
|
process.exitCode = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Args {
|
||||||
|
owner = ''
|
||||||
|
repo = ''
|
||||||
|
ignoreTags = []
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the command line args
|
||||||
|
* @returns {Args}
|
||||||
|
*/
|
||||||
|
function getArgs() {
|
||||||
|
const parsedArgs = argHelper.parse([], ['ignore-tags'])
|
||||||
|
const result = new Args()
|
||||||
|
|
||||||
|
// Validate ignore-tags is provided
|
||||||
|
if (!parsedArgs.options['ignore-tags']) {
|
||||||
|
argHelper.throwError('--ignore-tags is required')
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse ignore-tags (comma-separated version prefixes like v1,v2)
|
||||||
|
const prefixes = parsedArgs.options['ignore-tags'].split(',').map(t => t.trim()).filter(t => t)
|
||||||
|
for (const prefix of prefixes) {
|
||||||
|
// Convert simple version prefix like "v1" to regex pattern "^v1(\\..*)?$"
|
||||||
|
// This matches "v1", "v1.0", "v1.0.0", etc.
|
||||||
|
const escapedPrefix = prefix.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
||||||
|
result.ignoreTags.push(`^${escapedPrefix}(\\..*)?$`)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate exactly one arg
|
||||||
|
if (parsedArgs.arguments.length !== 1) {
|
||||||
|
argHelper.throwError('Expected exactly one arg (nwo)')
|
||||||
|
}
|
||||||
|
|
||||||
|
const nwo = parsedArgs.arguments[0]
|
||||||
|
const splitNwo = nwo.split('/')
|
||||||
|
if (splitNwo.length !== 2 || !splitNwo[0] || !splitNwo[1]) {
|
||||||
|
argHelper.throwError(`Invalid nwo '${nwo}'`)
|
||||||
|
}
|
||||||
|
result.owner = splitNwo[0]
|
||||||
|
result.repo = splitNwo[1]
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
function printUsage() {
|
||||||
|
console.error('USAGE: add-ignore-tags.sh --ignore-tags versions nwo')
|
||||||
|
console.error(` --ignore-tags Comma-separated version prefixes to ignore. For example: v1,v2`)
|
||||||
|
console.error(` nwo Name with owner. For example: actions/checkout`)
|
||||||
|
}
|
||||||
|
|
||||||
|
main()
|
||||||
@@ -40,6 +40,10 @@ for json_file in $script_dir/../../config/actions/*.json; do
|
|||||||
curl_download_commands+=("curl -s -S -L -o '$sha.zip' 'https://api.github.com/repos/$owner/$repo/zipball/$sha'")
|
curl_download_commands+=("curl -s -S -L -o '$sha.zip' 'https://api.github.com/repos/$owner/$repo/zipball/$sha'")
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Get an array of ignoreTags patterns (if present)
|
||||||
|
ignore_patterns=()
|
||||||
|
IFS=$'\n' read -r -d '' -a ignore_patterns < <( echo "$json" | jq --raw-output '.ignoreTags // [] | .[]' && printf '\0' )
|
||||||
|
|
||||||
# Get an array of tag info. Each item contains "<tag> <commit_sha>"
|
# Get an array of tag info. Each item contains "<tag> <commit_sha>"
|
||||||
tag_info=()
|
tag_info=()
|
||||||
IFS=$'\n' read -r -d '' -a tag_info < <( echo "$json" | jq --raw-output '.tags | to_entries | .[] | .key + " " + .value.commit' && printf '\0' )
|
IFS=$'\n' read -r -d '' -a tag_info < <( echo "$json" | jq --raw-output '.tags | to_entries | .[] | .key + " " + .value.commit' && printf '\0' )
|
||||||
@@ -49,6 +53,20 @@ for json_file in $script_dir/../../config/actions/*.json; do
|
|||||||
tag="${split[0]}"
|
tag="${split[0]}"
|
||||||
sha="${split[1]}"
|
sha="${split[1]}"
|
||||||
|
|
||||||
|
# Check if the tag matches any ignore pattern
|
||||||
|
skip_tag=false
|
||||||
|
for pattern in "${ignore_patterns[@]}"; do
|
||||||
|
if [[ "$tag" =~ $pattern ]]; then
|
||||||
|
echo "Ignoring tag '$tag' (matches pattern '$pattern')"
|
||||||
|
skip_tag=true
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$skip_tag" = true ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
# Append curl download command
|
# Append curl download command
|
||||||
curl_download_commands+=("curl -s -S -L -o '$sha.tar.gz' 'https://api.github.com/repos/$owner/$repo/tarball/$sha'")
|
curl_download_commands+=("curl -s -S -L -o '$sha.tar.gz' 'https://api.github.com/repos/$owner/$repo/tarball/$sha'")
|
||||||
curl_download_commands+=("curl -s -S -L -o '$sha.zip' 'https://api.github.com/repos/$owner/$repo/zipball/$sha'")
|
curl_download_commands+=("curl -s -S -L -o '$sha.zip' 'https://api.github.com/repos/$owner/$repo/zipball/$sha'")
|
||||||
|
|||||||
@@ -22,8 +22,9 @@ async function main() {
|
|||||||
const repo = config.repo
|
const repo = config.repo
|
||||||
const patterns = config.patterns
|
const patterns = config.patterns
|
||||||
const defaultBranch = config.defaultBranch
|
const defaultBranch = config.defaultBranch
|
||||||
|
const ignoreTags = config.ignoreTags
|
||||||
assert.ok(patterns && patterns.length, 'Existing patterns must not be empty')
|
assert.ok(patterns && patterns.length, 'Existing patterns must not be empty')
|
||||||
await actionConfig.add(owner, repo, patterns, defaultBranch)
|
await actionConfig.add(owner, repo, patterns, defaultBranch, ignoreTags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user