From cf8e5bcf20b2165e0248190b8efd692cd6ccc7c4 Mon Sep 17 00:00:00 2001 From: Philip Ellis Date: Tue, 5 Dec 2023 14:27:56 -0600 Subject: [PATCH] added delete infra task --- .github/workflows/pr-infra-destroy.yml | 58 ++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/pr-infra-destroy.yml diff --git a/.github/workflows/pr-infra-destroy.yml b/.github/workflows/pr-infra-destroy.yml new file mode 100644 index 00000000000..7a8f18cd5de --- /dev/null +++ b/.github/workflows/pr-infra-destroy.yml @@ -0,0 +1,58 @@ +name: Build/Deploy to AWS + +on: + # Runs on pushes targeting the default branch + pull_request: + types: [closed] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Allow one concurrent deployment +concurrency: + group: 'aws' + cancel-in-progress: true + +env: + BASE_URL: '/' + +permissions: + id-token: write # This is required for requesting the JWT + contents: read + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Configure AWS credentials from Test account + uses: aws-actions/configure-aws-credentials@v3 + with: + role-to-assume: arn:aws:iam::176038645705:role/github-action-role + role-session-name: deploy-developer-site-infra-to-aws + aws-region: us-east-1 + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: Check out repo + uses: actions/checkout@v3 + - name: setup SAM + uses: aws-actions/setup-sam@v2 + - name: set env vars + run: | + if [ "${{ github.ref }}" = "refs/heads/main" ]; then + echo "STACK=developer-sailpoint-site" >> $GITHUB_ENV + elif [[ ${{ github.ref }} == refs/pull/* ]]; then + PR_NUMBER=$(echo ${{ github.ref }} | awk -F '/' '{print $3}') + echo "STACK=developer-sailpoint-site-$PR_NUMBER" >> $GITHUB_ENV + elif [ "${{ github.ref }}" = "refs/heads/stage" ]; then + echo "STACK=developer-sailpoint-site-stage" >> $GITHUB_ENV + fi + - name: Get S3 bucket location and cloudfront url + run: | + export S3_BUCKET=$(aws cloudformation describe-stacks --stack-name $STACK --query "Stacks[0].Outputs[?OutputKey=='DeveloperSailpointWebS3BucketName'].OutputValue" --output text) + echo "S3_BUCKET=$S3_BUCKET" >> $GITHUB_ENV + export CLOUDFRONT_URL=$(aws cloudformation describe-stacks --stack-name $STACK --query "Stacks[0].Outputs[?OutputKey=='DeveloperSailpointCloudFrontDistributionDomainName'].OutputValue" --output text) + echo "CLOUDFRONT_URL=$CLOUDFRONT_URL" >> $GITHUB_ENV + - name: run SAM delete + run: | + aws s3 rm s3://$S3_BUCKET --recursive + sam delete --stack-name $STACK --no-prompts \ No newline at end of file