diff --git a/.github/workflows/promote.yml b/.github/workflows/promote.yml index 30a206c..f8a596f 100644 --- a/.github/workflows/promote.yml +++ b/.github/workflows/promote.yml @@ -7,6 +7,10 @@ on: path: description: 'path to promote' required: true + recursive: + description: 'is the path a directory' + type: boolean + required: true jobs: promote-release: @@ -14,6 +18,9 @@ jobs: runs-on: ubuntu-latest steps: + - name: Git Checkout + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + - name: Setup Node uses: actions/setup-node@v4 with: @@ -24,5 +31,5 @@ jobs: env: CF_ACCESS_KEY_ID: ${{ secrets.CF_ACCESS_KEY_ID }} CF_SECRET_ACCESS_KEY: ${{ secrets.CF_SECRET_ACCESS_KEY }} - runs: | - node scripts/promote-release.js ${{ inputs.path }} + run: | + node scripts/promote-release.mjs ${{ inputs.path }} ${{ inputs.recursive == true && '--recursive' || '' }} diff --git a/scripts/promote-release.mjs b/scripts/promote-release.mjs index f65213e..2bcbc66 100755 --- a/scripts/promote-release.mjs +++ b/scripts/promote-release.mjs @@ -1,8 +1,8 @@ #!/usr/bin/env node /** - * Usage: `promote-release ` - * ex/ `promote-release nodejs/release/v20.0.0` + * Usage: `promote-release [--recursive]` + * ex/ `promote-release nodejs/release/v20.0.0/ --recursive` */ import { @@ -17,8 +17,10 @@ import { R2_RETRY_COUNT, } from './constants.mjs'; -if (process.argv.length !== 3) { - console.error(`usage: promote-release `); +if (process.argv.length !== 3 && process.argv.length !== 4) { + console.error( + `usage: promote-release [--recursive]` + ); process.exit(1); } @@ -42,9 +44,16 @@ const client = new S3Client({ }); const path = process.argv[2]; -const files = await getFilesToPromote(path); +const recursive = + process.argv.length === 4 && process.argv[3] === '--recursive'; -for (const file of files) { +if (recursive) { + const files = await getFilesToPromote(path); + + for (const file of files) { + await promoteFile(file); + } +} else { await promoteFile(file); }