Skip to content

Delete Experiment

Delete Experiment #34

# 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
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