Skip to content

Instantly share code, notes, and snippets.

@varqasim
Created November 22, 2020 18:02
Show Gist options
  • Save varqasim/267c9b7174ef7a6afbb2ce2aa40a1669 to your computer and use it in GitHub Desktop.
Save varqasim/267c9b7174ef7a6afbb2ce2aa40a1669 to your computer and use it in GitHub Desktop.
name: PR Merged
on:
pull_request:
types: [closed]
jobs:
destroy:
name: Destroy Pulumi Stack and Resources
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Install infra dependencies
run: cd infra && npm ci
- uses: actions/setup-node@v1
with:
node-version: "12"
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v2.x
- name: Create PR_STACK_NAME env variable
run: echo "PR_STACK_NAME=$(echo $GITHUB_BASE_REF_SLUG | cut -c 1-3)-$(echo $GITHUB_HEAD_REF_SLUG | cut -c 1-15 | sed 's:-*$::')" >> $GITHUB_ENV
- name: Destroy the PR stack and resources
run: cd infra/automation && node index.js destroy
env:
PR_STACK_NAME: ${{ env.PR_STACK_NAME }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
MONGODB_ATLAS_PUBLIC_KEY: ${{ secrets.MONGODB_ATLAS_PUBLIC_KEY }}
MONGODB_ATLAS_PRIVATE_KEY: ${{ secrets.MONGODB_ATLAS_PRIVATE_KEY }}
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
PULUMI_ROOT: infra
PULUMI_CI: pr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment