Skip to content

Commit

Permalink
chore: fix dry run automation
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhousley committed Dec 1, 2023
1 parent 1c98d29 commit 5cf6a87
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/actions/s3-upload/args.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const args = yargs(hideBin(process.argv))
.boolean('dry')
.default('dry', false)
.describe('dry', 'Runs the action script without actually uploading files.')
.alias('dry', 'dry-run')

.string('dir')
.describe('dir', 'Bucket sub-directory name. Leave empty to upload to the root of the bucket.')
Expand Down
1 change: 1 addition & 0 deletions .github/actions/update-current/args.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const args = yargs(hideBin(process.argv))
.boolean('dry')
.default('dry', false)
.describe('dry', 'Runs the action script without actually uploading files.')
.alias('dry', 'dry-run')

.demandOption(['bucket', 'role', 'loader-version'])
.argv
10 changes: 9 additions & 1 deletion .github/actions/update-current/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ const results = await Promise.all(
TaggingDirective: 'COPY'
}

if (args.dry) {
console.log('running in dry mode, file not uploaded, params:', JSON.stringify({
...commandOpts,
Body: '[file stream]'
}))
return Promise.resolve()
}

const result = await s3Client.send(new CopyObjectCommand(commandOpts))
return ({
...result,
Expand Down Expand Up @@ -73,4 +81,4 @@ Output example:
*/

core.setOutput('results', JSON.stringify(results))
console.log(`Successfully copied ${results.length} files in S3`)
console.log(`Successfully ${args.dry ? 'simulated' : ''} copy of ${results.length} files in S3`)
35 changes: 31 additions & 4 deletions .github/workflows/publish-internal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,43 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: lts/*
- name: Prepare target environment
id: target-environment
run: |
if [[ "${{ inputs.nr_environment }}" == "prod" ]]; then
echo "nrba_app_id=${{ secrets.INTERNAL_PRODUCTION_APPLICATION_ID }}" >> $GITHUB_OUTPUT
echo "nrba_license_key=${{ secrets.INTERNAL_LICENSE_KEY }}" >> $GITHUB_OUTPUT
echo "nrba_ab_app_id=" >> $GITHUB_OUTPUT
echo "nrba_ab_license_key=" >> $GITHUB_OUTPUT
elif [[ "${{ inputs.nr_environment }}" == "eu-prod" ]]; then
echo "nrba_app_id=${{ secrets.INTERNAL_EU_PRODUCTION_APPLICATION_ID }}" >> $GITHUB_OUTPUT
echo "nrba_license_key=${{ secrets.INTERNAL_LICENSE_KEY }}" >> $GITHUB_OUTPUT
echo "nrba_ab_app_id=" >> $GITHUB_OUTPUT
echo "nrba_ab_license_key=" >> $GITHUB_OUTPUT
elif [[ "${{ inputs.nr_environment }}" == "staging" ]]; then
echo "nrba_app_id=${{ secrets.INTERNAL_STAGING_APPLICATION_ID }}" >> $GITHUB_OUTPUT
echo "nrba_license_key=${{ secrets.INTERNAL_LICENSE_KEY }}" >> $GITHUB_OUTPUT
echo "nrba_ab_app_id=${{ secrets.INTERNAL_AB_STAGING_APPLICATION_ID }}" >> $GITHUB_OUTPUT
echo "nrba_ab_license_key=${{ secrets.INTERNAL_AB_LICENSE_KEY }}" >> $GITHUB_OUTPUT
elif [[ "${{ inputs.nr_environment }}" == "dev" ]]; then
echo "nrba_app_id=${{ secrets.INTERNAL_DEV_APPLICATION_ID }}" >> $GITHUB_OUTPUT
echo "nrba_license_key=${{ secrets.INTERNAL_LICENSE_KEY }}" >> $GITHUB_OUTPUT
echo "nrba_ab_app_id=${{ secrets.INTERNAL_AB_DEV_APPLICATION_ID }}" >> $GITHUB_OUTPUT
echo "nrba_ab_license_key=${{ secrets.INTERNAL_AB_LICENSE_KEY }}" >> $GITHUB_OUTPUT
else
echo "Invalid environment select"
exit 1
fi
- name: Deploy prod a/b script
uses: ./.github/actions/internal-ab
with:
nr_environment: ${{ inputs.nr_environment }}
nrba_released_script_url: ${{ inputs.nrba_released_script_url }}
nrba_latest_script_url: ${{ inputs.nrba_latest_script_url }}
nrba_app_id: ${{ secrets.INTERNAL_PRODUCTION_APPLICATION_ID }}
nrba_license_key: ${{ secrets.INTERNAL_LICENSE_KEY }}
nrba_ab_app_id: ${{ secrets.INTERNAL_AB_DEV_APPLICATION_ID }}
nrba_ab_license_key: ${{ secrets.INTERNAL_AB_LICENSE_KEY }}
nrba_app_id: ${{ steps.target-environment.outputs.nrba_app_id }}
nrba_license_key: ${{ steps.target-environment.outputs.nrba_license_key }}
nrba_ab_app_id: ${{ steps.target-environment.outputs.nrba_ab_app_id }}
nrba_ab_license_key: ${{ steps.target-environment.outputs.nrba_ab_license_key }}
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_role: ${{ secrets.AWS_ROLE_ARN }}
Expand Down

0 comments on commit 5cf6a87

Please sign in to comment.