-
Notifications
You must be signed in to change notification settings - Fork 8
141 lines (135 loc) · 3.86 KB
/
cicd.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
name: CI/CD
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
testbuild:
name: Test and Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '20.x'
- name: Install Dependencies
run: npm ci
- name: Run Unit Tests
run: npm run test:ci
- name: Run Linter
run: npm run lint
- name: Run Build
run: npm run build
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run E2E Tests
run: npm run test:e2e
- name: Upload E2E Test Results
uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
- name: Upload Build artifact
uses: actions/upload-artifact@v3
if: always()
with:
name: dist
path: dist
retention-days: 30
deploystage:
name: Deploy to Staging
runs-on: ubuntu-latest
environment:
name: staging
url: https://dndbattletracker.com/stage/
concurrency:
group: staging
cancel-in-progress: true
needs: testbuild
if: github.event_name == 'push'
permissions:
id-token: write
contents: read
steps:
- name: Download Build artifact
uses: actions/download-artifact@v3
with:
name: dist
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
role-to-assume: arn:aws:iam::341118543232:role/github-s3-access
aws-region: eu-west-2
- name: Deploy to Staging
run: aws s3 sync . s3://dndbattletracker.com/stage/
deployprodpreflight:
name: Deploy to Production Preflight Checks
runs-on: ubuntu-latest
needs: deploystage
if: github.event_name == 'push'
outputs:
versionchanged: ${{ steps.versioncheck.outputs.changed }}
version: ${{ steps.versioncheck.outputs.version }}
steps:
- uses: actions/checkout@v3
- name: Check if version has been updated
id: versioncheck
uses: EndBug/version-check@v2
with:
diff-search: true
deployprod:
name: Deploy to Production
runs-on: ubuntu-latest
environment:
name: production
url: https://dndbattletracker.com/
concurrency:
group: production
cancel-in-progress: true
needs: deployprodpreflight
if: github.event_name == 'push' && needs.deployprodpreflight.outputs.versionchanged == 'true'
permissions:
id-token: write
contents: read
steps:
- name: Download Build artifact
uses: actions/download-artifact@v3
with:
name: dist
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
role-to-assume: arn:aws:iam::341118543232:role/github-s3-access-production
aws-region: eu-west-2
- name: Deploy to Production
run: aws s3 sync . s3://dndbattletracker.com/
githubrelease:
name: Github Release
runs-on: ubuntu-latest
needs: [deployprodpreflight, deployprod]
if: github.event_name == 'push'
permissions:
contents: write
id-token: write
steps:
- name: Download Build artifact
uses: actions/download-artifact@v3
with:
name: dist
- name: Create release artifact
uses: vimtor/[email protected]
with:
files: ./
recursive: true
dest: dnd-battle-tracker.zip
- name: Create release
uses: ncipollo/release-action@v1
with:
commit: ${{ github.sha }}
makeLatest: true
body: ${{ github.event.head_commit.message }}
tag: "v${{ needs.deployprodpreflight.outputs.version }}"
artifacts: "dnd-battle-tracker.zip"