Skip to content

Commit

Permalink
chore: add staging cdn purging (#906)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhousley authored Feb 29, 2024
1 parent 4d8f98a commit 8ae4d13
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 23 deletions.
24 changes: 18 additions & 6 deletions .github/workflows/publish-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
- name: Build dev
run: npm run cdn:build:dev
- name: Upload dev
id: dev-s3-upload
id: s3-upload
uses: ./.github/actions/s3-upload
with:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
Expand All @@ -63,21 +63,33 @@ jobs:
aws_bucket_name: ${{ secrets.AWS_BUCKET }}
local_dir: $GITHUB_WORKSPACE/build
bucket_dir: dev/
- name: Gather dev purge paths
- name: Gather cdn purge paths
id: dev-purge-paths
run: echo "results=$(echo '${{ steps.dev-s3-upload.outputs.results }}' | jq -j '.[].Key + " "')" >> $GITHUB_OUTPUT
- name: Purge dev fastly cache
run: echo "results=$(echo '${{ steps.s3-upload.outputs.results }}' | jq -j '.[].Key + " "')" >> $GITHUB_OUTPUT
- name: Purge production cdn
uses: ./.github/actions/fastly-purge
with:
fastly_key: ${{ secrets.FASTLY_PURGE_KEY }}
fastly_service: js-agent.newrelic.com
purge_path: ${{ steps.dev-purge-paths.outputs.results }}
- name: Verify dev assets
- name: Purge staging cdn
uses: ./.github/actions/fastly-purge
with:
fastly_key: ${{ secrets.FASTLY_PURGE_KEY }}
fastly_service: staging-js-agent.newrelic.com
purge_path: ${{ steps.dev-purge-paths.outputs.results }}
- name: Verify production cdn assets
uses: ./.github/actions/fastly-verify
with:
fastly_key: ${{ secrets.FASTLY_PURGE_KEY }}
fastly_service: js-agent.newrelic.com
asset_path: ${{ join(fromJson(steps.dev-s3-upload.outputs.results).*.Key, ' ') }}
asset_path: ${{ join(fromJson(steps.s3-upload.outputs.results).*.Key, ' ') }}
- name: Verify staging cdn assets
uses: ./.github/actions/fastly-verify
with:
fastly_key: ${{ secrets.FASTLY_PURGE_KEY }}
fastly_service: staging-js-agent.newrelic.com
asset_path: ${{ join(fromJson(steps.s3-upload.outputs.results).*.Key, ' ') }}

# Publish dev to staging NRDB
# publish-dev-nr:
Expand Down
20 changes: 19 additions & 1 deletion .github/workflows/publish-experiment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,30 @@ jobs:
- name: Gather purge paths
id: purge-paths
run: echo "results=$(echo '${{ steps.s3-upload.outputs.results }}' | jq -j '.[].Key | select(. | test("nr-loader-.*?\\.js$") or test(".*stats\\.json$")) + " "')" >> $GITHUB_OUTPUT
- name: Purge fastly cache
- name: Purge production cdn
uses: ./.github/actions/fastly-purge
with:
fastly_key: ${{ secrets.FASTLY_PURGE_KEY }}
fastly_service: js-agent.newrelic.com
purge_path: ${{ steps.purge-paths.outputs.results }}
- name: Purge staging cdn
uses: ./.github/actions/fastly-purge
with:
fastly_key: ${{ secrets.FASTLY_PURGE_KEY }}
fastly_service: staging-js-agent.newrelic.com
purge_path: ${{ steps.purge-paths.outputs.results }}
- name: Verify production cdn assets
uses: ./.github/actions/fastly-verify
with:
fastly_key: ${{ secrets.FASTLY_PURGE_KEY }}
fastly_service: js-agent.newrelic.com
asset_path: ${{ join(fromJson(steps.s3-upload.outputs.results).*.Key, ' ') }}
- name: Verify staging cdn assets
uses: ./.github/actions/fastly-verify
with:
fastly_key: ${{ secrets.FASTLY_PURGE_KEY }}
fastly_service: staging-js-agent.newrelic.com
asset_path: ${{ join(fromJson(steps.s3-upload.outputs.results).*.Key, ' ') }}

# Rebuild and publish the environment A/B script
publish-ab:
Expand Down
56 changes: 40 additions & 16 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,41 @@ jobs:
- name: Build prod
run: npm run cdn:build:prod
- name: Upload prod
id: prod-s3-upload
id: s3-upload
uses: ./.github/actions/s3-upload
with:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_role: ${{ secrets.AWS_ROLE_ARN }}
aws_bucket_name: ${{ secrets.AWS_BUCKET }}
local_dir: $GITHUB_WORKSPACE/build
- name: Gather prod purge paths
id: prod-purge-paths
run: echo "results=$(echo '${{ steps.prod-s3-upload.outputs.results }}' | jq -j '.[].Key | select(. | test("nr-loader-.*?\\.js$") or test(".*stats\\.json$")) + " "')" >> $GITHUB_OUTPUT
- name: Purge prod fastly cache
- name: Gather cdn purge paths
id: purge-paths
run: echo "results=$(echo '${{ steps.s3-upload.outputs.results }}' | jq -j '.[].Key | select(. | test("nr-loader-.*?\\.js$") or test(".*stats\\.json$")) + " "')" >> $GITHUB_OUTPUT
- name: Purge production cdn
uses: ./.github/actions/fastly-purge
with:
fastly_key: ${{ secrets.FASTLY_PURGE_KEY }}
fastly_service: js-agent.newrelic.com
purge_path: ${{ steps.prod-purge-paths.outputs.results }}
- name: Verify prod assets
purge_path: ${{ steps.purge-paths.outputs.results }}
- name: Purge staging cdn
uses: ./.github/actions/fastly-purge
with:
fastly_key: ${{ secrets.FASTLY_PURGE_KEY }}
fastly_service: staging-js-agent.newrelic.com
purge_path: ${{ steps.purge-paths.outputs.results }}
- name: Verify production cdn assets
uses: ./.github/actions/fastly-verify
with:
fastly_key: ${{ secrets.FASTLY_PURGE_KEY }}
fastly_service: js-agent.newrelic.com
asset_path: ${{ join(fromJson(steps.prod-s3-upload.outputs.results).*.Key, ' ') }}
asset_path: ${{ join(fromJson(steps.s3-upload.outputs.results).*.Key, ' ') }}
- name: Verify staging cdn assets
uses: ./.github/actions/fastly-verify
with:
fastly_key: ${{ secrets.FASTLY_PURGE_KEY }}
fastly_service: staging-js-agent.newrelic.com
asset_path: ${{ join(fromJson(steps.s3-upload.outputs.results).*.Key, ' ') }}

# Publish the new "current" version to s3 before the prod a/b scripts have been built
publish-current-to-s3:
Expand All @@ -67,29 +79,41 @@ jobs:
id: agent-loader-version
run: echo "results=$(cat package.json | jq -r '.version')" >> $GITHUB_OUTPUT
- name: Copy loaders to current
id: current-s3-update
id: s3-upload
uses: ./.github/actions/update-current
with:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_role: ${{ secrets.AWS_ROLE_ARN }}
aws_bucket_name: ${{ secrets.AWS_BUCKET }}
loader_version: ${{ steps.agent-loader-version.outputs.results }}
- name: Gather current purge paths
id: current-purge-paths
run: echo "results=$(echo '${{ steps.current-s3-update.outputs.results }}' | jq -j '.[].Key + " "')" >> $GITHUB_OUTPUT
- name: Purge current fastly cache
- name: Gather cdn purge paths
id: purge-paths
run: echo "results=$(echo '${{ steps.s3-upload.outputs.results }}' | jq -j '.[].Key + " "')" >> $GITHUB_OUTPUT
- name: Purge production cdn
uses: ./.github/actions/fastly-purge
with:
fastly_key: ${{ secrets.FASTLY_PURGE_KEY }}
fastly_service: js-agent.newrelic.com
purge_path: ${{ steps.current-purge-paths.outputs.results }}
- name: Verify current assets
purge_path: ${{ steps.purge-paths.outputs.results }}
- name: Purge staging cdn
uses: ./.github/actions/fastly-purge
with:
fastly_key: ${{ secrets.FASTLY_PURGE_KEY }}
fastly_service: staging-js-agent.newrelic.com
purge_path: ${{ steps.purge-paths.outputs.results }}
- name: Verify production cdn assets
uses: ./.github/actions/fastly-verify
with:
fastly_key: ${{ secrets.FASTLY_PURGE_KEY }}
fastly_service: js-agent.newrelic.com
asset_path: ${{ join(fromJson(steps.current-s3-update.outputs.results).*.Key, ' ') }}
asset_path: ${{ join(fromJson(steps.s3-upload.outputs.results).*.Key, ' ') }}
- name: Verify staging cdn assets
uses: ./.github/actions/fastly-verify
with:
fastly_key: ${{ secrets.FASTLY_PURGE_KEY }}
fastly_service: staging-js-agent.newrelic.com
asset_path: ${{ join(fromJson(steps.s3-upload.outputs.results).*.Key, ' ') }}

# Rebuild and publish the prod environment A/B script
publish-prod-ab:
Expand Down

0 comments on commit 8ae4d13

Please sign in to comment.