-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (74 loc) · 2.37 KB
/
deploy.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Deploy
on:
# To re-enable "prod" deploy, uncomment following lines.
#
# push:
# branches:
# - main
pull_request:
branches:
- main
jobs:
deploy:
if: |
github.actor != 'dependabot[bot]' ||
github.actor != 'github-actions[bot]' ||
github.actor != 'mergify[bot]'
name: Deploy to AWS
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: eu-west-1
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-session-name: github-actions-session
- name: Install Dependencies
run: yarn --frozen-lockfile
- name: Set CDK Application Stage
id: stage
run: |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
echo ::set-output name=stage::"prod"
else
echo ::set-output name=stage::"pr-${{ github.event.number }}"
fi
- name: Create GitHub Deployment
uses: bobheadxi/deployments@v1
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: ${{ steps.stage.outputs.stage }}
ref: ${{ github.head_ref }}
# - name: Bootstrap the CDK environment
# run: npx cdk bootstrap
- name: Diff?
run: npx cdk diff --context stage=${{ steps.stage.outputs.stage }}
- name: Deploy!
id: deploy
run: |
npx cdk deploy \
--require-approval never \
--outputs-file outputs.json \
--context stage=${{ steps.stage.outputs.stage }}
echo ::set-output name=env_url::"http://$(jq -r '.[] | select(.serviceloadbalancerdnsoutput).serviceloadbalancerdnsoutput' outputs.json)"
- name: Update GitHub Deployment Status
uses: bobheadxi/deployments@v1
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env_url: ${{ steps.deploy.outputs.env_url }}