-
Notifications
You must be signed in to change notification settings - Fork 23
150 lines (147 loc) · 4.54 KB
/
CD.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
name: CD
on:
push:
branches:
- master
env:
NODE_ENV: production
NODE_VERSION: 15.x
jobs:
semantic-release:
name: "Semantic Release 🗂"
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-20.04
env:
CI: true
GIT_AUTHOR_NAME: ${{ github.event.pusher.name }}
GIT_AUTHOR_EMAIL: ${{ github.event.pusher.email }}
GIT_COMMITTER_NAME: St. Jude Cloud
GIT_COMMITTER_EMAIL: [email protected]
HUSKY: 0
NODE_ENV: development
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- uses: actions/setup-python@v4
with:
python-version: "pypy2.7"
- name: Cache NPM dependencies
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-release-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-release-
- name: Install Node Dependencies
run: npm install
- name: Build and Publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npx semantic-release
git describe --tags --abbrev=0 > ./VERSION
- name: Upload Version File
uses: actions/upload-artifact@v4
with:
name: version-file
path: ./VERSION
if-no-files-found: error
retention-days: 3
- name: Print Version Number
run: cat ./VERSION
build:
name: "Gatsby Build 🧰"
runs-on: ubuntu-20.04
needs: [semantic-release]
env:
CI: true
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- uses: actions/setup-python@v4
with:
python-version: "pypy2.7"
- name: Cache NPM dependencies
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-build-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-
- name: Install Node Dependencies
run: npm install
env:
NODE_ENV: development
- name: Cache Gatsby folder
uses: actions/cache@v2
with:
path: .cache
key: ${{ runner.os }}-cache-gatsby
restore-keys: |
${{ runner.os }}-cache-gatsby
- name: Cache Public folder
uses: actions/cache@v2
with:
path: public/
key: ${{ runner.os }}-public-gatsby
restore-keys: |
${{ runner.os }}-public-gatsby
- uses: actions/download-artifact@v4
with:
name: version-file
path: .
- name: Run Build
run: |
GATSBY_DOCS_VERSION=$(cat ./VERSION) GATSBY_DOCS_HASH=$(git rev-parse --short "$GITHUB_SHA") npm run build
env:
GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES: true
NODE_ENV: production
ALGOLIA_ADMIN_KEY: ${{ secrets.ALGOLIA_ADMIN_KEY }}
GATSBY_ALGOLIA_APP_ID: ${{ secrets.GATSBY_ALGOLIA_APP_ID }}
GATSBY_ALGOLIA_SEARCH_KEY: ${{ secrets.GATSBY_ALGOLIA_SEARCH_KEY }}
INTERCOM_APP_ID: ${{ secrets.INTERCOM_APP_ID }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Built Site
uses: actions/upload-artifact@v4
with:
name: gatsby-public-folder
path: public/
if-no-files-found: error
retention-days: 3
deploy:
name: "Deploy to Netlify 🚀"
if: github.ref == 'refs/heads/master'
needs: [build, semantic-release]
runs-on: ubuntu-latest
env:
CI: true
steps:
- uses: actions/download-artifact@v4
with:
name: gatsby-public-folder
path: public/
- name: Display structure of downloaded files
run: ls -R
working-directory: public/
- name: Deploy to Netlify
uses: nwtgck/[email protected]
with:
publish-dir: "./public"
production-branch: master
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: "Deploy from GitHub Actions"
enable-pull-request-comment: false
enable-commit-comment: true
overwrites-pull-request-comment: true
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
timeout-minutes: 10