Skip to content

Remove Feature Branch (SST) #133

Remove Feature Branch (SST)

Remove Feature Branch (SST) #133

name: Remove Feature Branch (SST)
on:
delete:
branches:
- 'feature/**'
jobs:
DeleteFeatureSST:
if:
${{ github.event.ref_type == 'branch' && startsWith(github.event.ref,
'feature/') }}
runs-on: ubuntu-latest
steps:
- name: Git clone the repository
uses: actions/checkout@v4
with:
ref: 'main'
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::626762246796:role/GitHub
role-duration-seconds: 1200 #adjust as needed for your build time
aws-region: us-east-1
- name: Extract and format branch name
shell: bash
run: |
BRANCH_NAME=${{ github.event.ref }}
FORMATTED_BRANCH_NAME=$(echo "$BRANCH_NAME" | sed 's|/|-|g')
echo "FORMATTED_BRANCH_NAME=$FORMATTED_BRANCH_NAME" >> $GITHUB_ENV
id: extract_branch
- name: Run SST remove
run: |
echo "Clean up for branch $FORMATTED_BRANCH_NAME"
npm i && npx sst remove --stage $FORMATTED_BRANCH_NAME
# Concurrency group name ensures concurrent workflow runs wait for any in-progress job to finish
# In this case, we want the merge-<branh-name> group for the scenario where a branch is created
# (triggering a long deploy workflow) and then deleted (triggering this workflow which needs to start after)
concurrency:
group: merge-${{ github.event.ref }}
permissions:
contents: read # This is required for actions/checkout
id-token: write # This is required for requesting the JWT