Merge branch 'main' into NR-526518-notify-experiment-changes #31
Workflow file for this run
This file contains hidden or 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 run on any branch. | ||
| # Given an environment, this workflow will delete the branch's experiment from S3 | ||
| # and then republish the A/B scripts to remove the experiment from the environment. | ||
| name: Delete Experiment | ||
| permissions: | ||
| contents: read | ||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| nr_environment: | ||
| description: 'Target New Relic environment' | ||
| required: true | ||
| type: choice | ||
| options: | ||
| - dev | ||
| - staging | ||
| - standalone | ||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
| jobs: | ||
| delete-experiment-on-s3: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
| defaults: | ||
| run: | ||
| shell: bash | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - 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: 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: Delete experiment | ||
| id: s3-delete | ||
| uses: ./.github/actions/s3-delete | ||
| 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 }} | ||
| bucket_dir: experiments/${{ github.event.inputs.nr_environment }}/${{ steps.clean-branch-name.outputs.results }} | ||
| # Rebuild and republish dev after deletion | ||
| # This removes the deleted experiment from the environment | ||
| republish-dev: | ||
| if: ${{ inputs.nr_environment != 'standalone' }} | ||
| needs: [delete-experiment-on-s3] | ||
| uses: ./.github/workflows/publish-dev.yml | ||
| secrets: inherit | ||
| # Notify about experiments in Slack | ||
| send-slack-notifications: | ||
| if: ${{ inputs.nr_environment == 'staging' }} | ||
| needs: [delete-experiment-on-s3, republish-dev] | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
| defaults: | ||
| run: | ||
| shell: bash | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ github.ref }} | ||
| - 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: Send Slack notifications | ||
| uses: ./.github/actions/slack-notification | ||
| with: | ||
| notifications_channel_url: ${{ secrets.SLACK_BROWSER_AGENT_NOTIFICATIONS_WEBHOOK_URL }} | ||
| dem_platform_ops_channel_url: ${{ secrets.SLACK_DEM_PLATFORM_OPS_WEBHOOK_URL }} | ||
| message: ":red-x: Removed browser agent experiment in \\`${{ inputs.nr_environment }}\\` for branch \\`${{ steps.clean-branch-name.outputs.results }}\\`. See <https://github.com/newrelic/newrelic-browser-agent/actions/workflows/delete-experiment.yml|Delete Experiment> workflow." | ||