Skip to content

Commit 904e342

Browse files
committed
Add branch deletion step after Terraform apply in workflow
1 parent faf493e commit 904e342

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

.github/workflows/terraform-infra-apply.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,14 @@ jobs:
5555

5656
- name: Terraform Apply
5757
run: terraform apply -auto-approve -var-file="terraform.tfvars"
58-
working-directory: terraform/environments/${{ steps.env.outputs.env_name }}
58+
working-directory: terraform/environments/${{ steps.env.outputs.env_name }}
59+
- name: Delete apply branch
60+
if: startsWith(github.ref, 'refs/heads/apply/')
61+
env:
62+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
run: |
64+
BRANCH_NAME="${GITHUB_REF#refs/heads/}"
65+
echo "Deleting branch: $BRANCH_NAME"
66+
gh api \
67+
-X DELETE \
68+
/repos/${{ github.repository }}/git/refs/heads/$BRANCH_NAME

0 commit comments

Comments
 (0)