-
Notifications
You must be signed in to change notification settings - Fork 27
256 lines (206 loc) · 7.53 KB
/
build.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
name: build
on: [push, pull_request, merge_group]
env:
IMAGE_NAME: ${{ vars.REGISTRY_HOSTNAME }}/${{ vars.ICR_NAMESPACE }}/galasa.dev:${{ github.sha }}
jobs:
prettier:
name: Check code formatting
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- run: npm ci --legacy-peer-deps
- run: ./.github/scripts/prettier-check.sh
# Build the site to be deployed to galasa.dev
build-dotdev:
name: Build the galasa.dev site
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- uses: nelonoel/branch-name@v1.0.1
- run: npm ci --legacy-peer-deps
- run: npm run build
env:
BASE_REPO_SLUG: ${{ github.repository }}
PR_REPO_SLUG: ${{ github.event.pull_request.head.repo.full_name }}
PR_BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
- name: Serve the site
run: npm run serve &
- name: Check for broken links
run: npx broken-link-checker -ro --exclude /docs/managers/ --filter-level 3 --host-requests 8 --user-agent Chrome/90 --exclude https://fonts.gstatic.com/ --exclude https://github.com/galasa-dev/extensions/ http://localhost:9000
- name: Upload raw site
uses: actions/upload-artifact@v3
with:
name: output-dotdev-raw-site
path: public
# Wrap the site in an NGINX container and publish to a container registry
publish-dotdev:
name: Publish image to repository
runs-on: ubuntu-latest
needs: [ build-dotdev, prettier ]
if: (github.ref == 'refs/heads/main') || (github.ref == 'refs/heads/next')
steps:
- name: Checkout
uses: actions/checkout@v3
with:
path: repo
- name: Download raw site
uses: actions/download-artifact@v3
with:
name: output-dotdev-raw-site
path: site/public
- name: Merge site and NGINX configuration
run: cp -rv repo/ce/* site/
- name: Install IBM Cloud CLI
run: |
curl -fsSL https://clis.cloud.ibm.com/install/linux | sh
ibmcloud --version
ibmcloud config --check-version=false
ibmcloud plugin install -f container-registry
- name: Authenticate with IBM Cloud CLI
run: |
ibmcloud login --apikey "${{ secrets.IBM_CLOUD_API_KEY }}" --no-region -g ${{ vars.RESOURCE_GROUP }}
ibmcloud cr region-set global
ibmcloud cr login
- name: Install pack (Paketo) CLI
uses: buildpacks/github-actions/setup-pack@v5.0.0
- name: Build image with Paketo and publish to repository
run: |
pack build $IMAGE_NAME \
--buildpack gcr.io/paketo-buildpacks/nginx \
--builder paketobuildpacks/builder:base \
--path site \
--publish
# Deploy the site to galasa.dev
deploy-dotdev:
name: Deploy to galasa.dev
runs-on: ubuntu-latest
needs: [ publish-dotdev ]
if: github.ref == 'refs/heads/main'
strategy:
matrix:
region:
- name: us-south
- name: eu-gb
- name: au-syd
steps:
- name: Install IBM Cloud CLI
run: |
curl -fsSL https://clis.cloud.ibm.com/install/linux | sh
ibmcloud --version
ibmcloud config --check-version=false
ibmcloud plugin install -f code-engine
- name: Authenticate with IBM Cloud CLI
run: |
ibmcloud login --apikey "${{ secrets.IBM_CLOUD_API_KEY }}" -r "${{ matrix.region.name }}" -g ${{ vars.RESOURCE_GROUP }}
ibmcloud ce project select --name galasa-${{ matrix.region.name }}
- name: Update Code Engine application
run: |
ibmcloud ce application update \
--name galasa-${{ matrix.region.name }}-site \
--image $IMAGE_NAME
# Deploy to vnext
deploy-vnext:
name: Deploy to vnext.galasa.dev
runs-on: ubuntu-latest
needs: [ publish-dotdev ]
if: github.ref == 'refs/heads/next'
steps:
- name: Install IBM Cloud CLI
run: |
curl -fsSL https://clis.cloud.ibm.com/install/linux | sh
ibmcloud --version
ibmcloud config --check-version=false
ibmcloud plugin install -f code-engine
- name: Authenticate with IBM Cloud CLI
run: |
ibmcloud login --apikey "${{ secrets.IBM_CLOUD_API_KEY }}" -r "eu-gb" -g ${{ vars.RESOURCE_GROUP }}
ibmcloud ce project select --name galasa-eu-gb
- name: Update Code Engine application
run: |
ibmcloud ce application update \
--name galasa-eu-gb-next \
--image $IMAGE_NAME
# Immediately trigger a DocSearch crawl
crawl-docsearch:
name: Submit Algolia DocSearch crawler
runs-on: ubuntu-latest
needs: deploy-dotdev
steps:
- name: Algolia crawler creation and crawl
uses: algolia/algoliasearch-crawler-github-actions@v1.0.10
with:
crawler-user-id: ${{ secrets.CRAWLER_USER_ID }}
crawler-api-key: ${{ secrets.CRAWLER_API_KEY }}
crawler-name: galasa
algolia-app-id: ${{ secrets.ALGOLIA_APP_ID }}
algolia-api-key: ${{ secrets.ALGOLIA_API_KEY }}
site-url: 'https://galasa.dev'
# Build the site for local deployment in closed networks
build-local:
name: Build the local site
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- uses: nelonoel/branch-name@v1.0.1
- run: npm ci --legacy-peer-deps
- run: npm run build
env:
BASE_REPO_SLUG: ${{ github.repository }}
PR_REPO_SLUG: ${{ github.event.pull_request.head.repo.full_name }}
PR_BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
GATSBY_GALASA_ENV: "LOCAL"
- name: Serve the site
run: npm run serve &
- name: Check for broken links
run: npx broken-link-checker -ro --exclude /docs/managers/ --filter-level 3 --host-requests 8 --user-agent Chrome/90 --exclude https://fonts.gstatic.com/ --exclude https://github.com/galasa-dev/extensions/ http://localhost:9000
- name: Upload raw site
uses: actions/upload-artifact@v3
with:
name: output-local-raw-site
path: public
- name: Create WAR
run: ./.github/scripts/war.sh
- name: Upload WAR
uses: actions/upload-artifact@v3
with:
name: output-local-war
path: galasa.dev-site.war
build-local-runnable-jar:
name: Build a runnable JAR of the local site
runs-on: ubuntu-latest
needs: [ build-local, prettier ]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download WAR
uses: actions/download-artifact@v3
with:
name: output-local-war
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'adopt'
- name: Build with Gradle
run: ./gradlew --info libertyPackage
working-directory: package-jar
- name: Upload JAR
uses: actions/upload-artifact@v3
with:
name: output-local-jar
path: package-jar/build/libs/galasa.dev-runnable.jar