-
Notifications
You must be signed in to change notification settings - Fork 0
158 lines (133 loc) · 4.15 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: Deployment
on:
workflow_dispatch: {}
push:
branches:
- main
permissions:
id-token: write
contents: read
packages: write
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: ./.github/actions/install
- uses: ./.github/actions/verify
- name: Build Docker Image
run: docker build --tag ghcr.io/sourceallies/hacker-rank-queue:${{ github.sha }} .
- name: Push Docker Image
run: docker push ghcr.io/sourceallies/hacker-rank-queue:${{ github.sha }}
deploy-dev:
name: Deploy Dev
needs: build
runs-on: ubuntu-latest
concurrency: dev
environment: Development
env:
ENV_NAME: dev
IMAGE: ghcr.io/sourceallies/hacker-rank-queue:${{ github.sha }}
steps:
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: '18.x'
- name: Checkout Repo
uses: actions/checkout@v4
with:
lfs: true
- name: Cache Dependencies
uses: actions/cache@v4
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-node${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }}
- uses: ./.github/actions/install
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-1
role-to-assume: ${{ secrets.DEV_ROLE_ARN }}
- name: CDK Bootstrap
working-directory: ./.aws
run: pnpm cdk bootstrap
shell: bash
- name: Deploy
working-directory: ./.aws
run: pnpm infra:up
shell: bash
- name: Notify Slack Success
uses: slackapi/slack-github-action@v1.26.0
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
with:
channel-id: 'coding-exercise-queue'
slack-message: ':white_check_mark: Deployment to *dev* succeeded'
- name: Notify Slack Failure
uses: slackapi/slack-github-action@v1.26.0
if: ${{ failure() }}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
with:
channel-id: 'coding-exercise-queue'
slack-message: ':x: Deployment to *dev* failed'
deploy-prod:
name: Deploy Prod
needs: deploy-dev
runs-on: ubuntu-latest
concurrency: prod
environment: Production
env:
ENV_NAME: prod
IMAGE: ghcr.io/sourceallies/hacker-rank-queue:${{ github.sha }}
steps:
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: '18.x'
- name: Checkout Repo
uses: actions/checkout@v4
with:
lfs: true
- name: Cache Dependencies
uses: actions/cache@v4
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-node${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }}
- uses: ./.github/actions/install
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-1
role-to-assume: ${{ secrets.PROD_ROLE_ARN }}
- name: CDK Bootstrap
working-directory: ./.aws
run: pnpm cdk bootstrap
shell: bash
- name: Deploy
working-directory: ./.aws
run: pnpm infra:up
shell: bash
- name: Notify Slack Success
uses: slackapi/slack-github-action@v1.26.0
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
with:
channel-id: 'coding-exercise-queue'
slack-message: ':white_check_mark: Deployment to *prod* succeeded'
- name: Notify Slack Failure
uses: slackapi/slack-github-action@v1.26.0
if: ${{ failure() }}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
with:
channel-id: 'coding-exercise-queue'
slack-message: ':x: Deployment to *prod* failed'