-
-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (94 loc) · 3.04 KB
/
continuous-deployment.yml
File metadata and controls
111 lines (94 loc) · 3.04 KB
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
name: Continuous Deployment
env:
build-artifact-name: gitropolis-app
NODE_OPTIONS: --max-old-space-size=6144
on:
push:
branches:
- main
pull_request: {}
concurrency:
# Group concurrency on workflow, then:
# - Is merge run? Group `push` events
# - Is pull request? Group `pull_request` events
group:
${{ github.workflow }}-${{ github.event_name == 'push' && github.base_ref ||
github.head_ref }}
# Run merge runs in sequence. Cancel in progress pull request runs.
cancel-in-progress: ${{ github.event_name != 'push' }}
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
cache: yarn
node-version-file: .nvmrc
- name: Install package dependencies
run: yarn install --frozen-lockfile --non-interactive
- name: Lint all projects
run: yarn lint
test:
name: Unit and integration tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
cache: yarn
node-version-file: .nvmrc
- name: Install package dependencies
run: yarn install --frozen-lockfile --non-interactive
- name: Run all unit and integration tests
run: yarn test
build:
name: Build web app
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
cache: yarn
node-version-file: .nvmrc
- name: Install package dependencies
run: yarn install --frozen-lockfile --non-interactive
- name: Get GitHub repository name
id: repository-name
run: echo "::set-output name=name::$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')"
- name: Build web app
run: yarn build --base-href=/${{ steps.repository-name.outputs.name }}/
- name: Add 404 page with GitHub Pages support
run: cp build/github-pages/404.html ./dist/apps/${{ env.build-artifact-name }}/
- name: Upload web app build artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.build-artifact-name }}
path: ./dist/apps/${{ env.build-artifact-name }}/
if-no-files-found: error
deploy:
name: Deploy web app to GitHub Pages
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs:
- build
- lint
- test
runs-on: ubuntu-latest
env:
build-artifact-path: ./gitropolis-app/
steps:
# Necessary for JamesIves/github-pages-deploy-action
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: ${{ env.build-artifact-name }}
path: ${{ env.build-artifact-path }}
- name: Deploy docs to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: ${{ env.build-artifact-path }}