-
Notifications
You must be signed in to change notification settings - Fork 2
69 lines (57 loc) · 2.18 KB
/
pr-closed.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: Cleanup Merged PR
on:
pull_request:
types:
- closed
branches:
- main
workflow_dispatch:
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
NODE_ENV: prod
APP_NAME: release
APP_NAME_STORYBOOK: release-storybook
DEPLOYER_LAMBDA_NAME: microapps-core-ghpublic-deployer-prod
AWS_REGION: us-east-2
jobs:
cleanup-pr:
if: github.actor != 'dependabot[bot]'
concurrency:
group: pr-closed-${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: false
environment:
name: ghpublic
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
- name: Install microapps-publish
run: npm i -g @pwrdrvr/microapps-publish
- name: Extract Current NPM Version
run: |
echo 'PACKAGE_VERSION_ORIG='$(node -p -e "require('./package.json').version") >> $GITHUB_ENV
- name: Compute NPM Version
id: packageVersion
run: |
echo 'PACKAGE_VERSION='${PACKAGE_VERSION_ORIG}-pr.${PR_NUMBER} >> $GITHUB_ENV
echo "::set-output name=packageVersion::${PACKAGE_VERSION_ORIG}-pr.${PR_NUMBER}"
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
role-session-name: microapps-app-${{ env.APP_NAME }}-build
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/builder-writeRole
aws-region: ${{ env.AWS_REGION }}
- name: Delete App from MicroApps
run: |
npx microapps-publish delete -a ${APP_NAME} -n ${PACKAGE_VERSION} -d ${DEPLOYER_LAMBDA_NAME}
npx microapps-publish delete -a ${APP_NAME_STORYBOOK} -n ${PACKAGE_VERSION} -d ${DEPLOYER_LAMBDA_NAME}
- name: Destroy CDK Stack
run: |
aws cloudformation delete-stack --stack-name "microapps-app-${APP_NAME}-${NODE_ENV}-pr-${PR_NUMBER}"
aws cloudformation wait stack-delete-complete --no-paginate --output text --stack-name "microapps-app-${APP_NAME}-${NODE_ENV}-pr-${PR_NUMBER}"