Skip to content

Commit

Permalink
--recursive
Browse files Browse the repository at this point in the history
Signed-off-by: flakey5 <[email protected]>

Signed-off-by: flakey5 <[email protected]>
  • Loading branch information
flakey5 committed Oct 15, 2024
1 parent 443e2e8 commit fcd95a9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/promote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@ on:
path:
description: 'path to promote'
required: true
recursive:
description: 'is the path a directory'
type: boolean
required: true

jobs:
promote-release:
name: Promote Release
runs-on: ubuntu-latest

steps:
- name: Git Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744

- name: Setup Node
uses: actions/setup-node@v4
with:
Expand All @@ -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' || '' }}
21 changes: 15 additions & 6 deletions scripts/promote-release.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env node

/**
* Usage: `promote-release <prefix in dist-staging to promote>`
* ex/ `promote-release nodejs/release/v20.0.0`
* Usage: `promote-release <prefix in dist-staging to promote> [--recursive]`
* ex/ `promote-release nodejs/release/v20.0.0/ --recursive`
*/

import {
Expand All @@ -17,8 +17,10 @@ import {
R2_RETRY_COUNT,
} from './constants.mjs';

if (process.argv.length !== 3) {
console.error(`usage: promote-release <prefix in dist-staging to promote>`);
if (process.argv.length !== 3 && process.argv.length !== 4) {
console.error(
`usage: promote-release <prefix in dist-staging to promote> [--recursive]`
);
process.exit(1);
}

Expand All @@ -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);
}

Expand Down

0 comments on commit fcd95a9

Please sign in to comment.