Publish Experiment #207
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow can be ran on any branch to build and publish | |
# that branch as an internal experiment. Once published, the | |
# dev and staging A/B scripts will be updated to include the | |
# new experiment. | |
name: Publish Experiment | |
on: | |
workflow_dispatch: | |
inputs: | |
nr_environment: | |
description: 'Target New Relic environment' | |
required: true | |
type: choice | |
options: | |
- dev | |
- staging | |
jobs: | |
# Build and publish the branch to S3 experiments folder | |
publish-experiment-to-s3: | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref }} | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 22.11.0 # See package.json for the stable node version that works with our testing. Do not change this unless you know what you are doing as some node versions do not play nicely with our testing server. | |
- name: Install project dependencies | |
run: npm ci | |
- name: Clean branch name | |
id: clean-branch-name | |
run: echo "results=$(echo '${{ github.ref }}' | sed 's/refs\/heads\///g' | sed 's/[^[:alnum:].-]/-/g')" >> $GITHUB_OUTPUT | |
- name: Build experiment | |
run: npm run cdn:build:experiment -- --env branchName='${{ inputs.nr_environment }}/${{ steps.clean-branch-name.outputs.results }}' | |
- name: Upload experiment | |
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 | |
bucket_dir: experiments/${{ inputs.nr_environment }}/${{ steps.clean-branch-name.outputs.results }} | |
- name: Gather 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.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: | |
needs: [publish-experiment-to-s3] | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref }} | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 22.11.0 # See package.json for the stable node version that works with our testing. Do not change this unless you know what you are doing as some node versions do not play nicely with our testing server. | |
- name: Publish a/b script | |
uses: ./.github/actions/internal-ab | |
with: | |
nr_environment: ${{ inputs.nr_environment }} | |
nrba_app_id: ${{ inputs.nr_environment == 'dev' && secrets.INTERNAL_DEV_APPLICATION_ID || secrets.INTERNAL_STAGING_APPLICATION_ID }} | |
nrba_license_key: ${{ secrets.INTERNAL_LICENSE_KEY }} | |
nrba_ab_app_id: ${{ inputs.nr_environment == 'dev' && secrets.INTERNAL_AB_DEV_APPLICATION_ID || secrets.INTERNAL_AB_STAGING_APPLICATION_ID }} | |
nrba_ab_license_key: ${{ secrets.INTERNAL_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 }} | |
aws_bucket_name: ${{ secrets.AWS_BUCKET }} | |
fastly_key: ${{ secrets.FASTLY_PURGE_KEY }} |