Skip to content

Commit 1ab84b1

Browse files
authored
feat(ci): Migrate Review Site CircleCI jobs to GH Actions (#5105)
* make framework-build job * make publish-site job * remove review app jobs from CircleCI config
1 parent 59f18ad commit 1ab84b1

File tree

2 files changed

+116
-88
lines changed

2 files changed

+116
-88
lines changed

.circleci/config.yml

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ commands:
8181
source $BASH_ENV
8282
echo $HEROKU_APP_NAME > workspace/heroku-app-name.txt
8383
echo $HEROKU_RELEASE_STORYBOOK_APP_NAME > workspace/heroku-release-storybook-app-name.txt
84-
8584
- run: printenv | sort
8685

8786
- run:
@@ -95,7 +94,6 @@ commands:
9594
cat workspace/heroku-app-name.txt
9695
echo "=============================="
9796
echo
98-
9997
get-pr-number:
10098
description: 'Get Github pull-request number'
10199
steps:
@@ -117,7 +115,6 @@ commands:
117115
cat gh-pull-data.json
118116
echo "---------------------------------------"
119117
cat gh-pull-data.json | jq -r '.number' > workspace/gh-pr-num.txt && cat workspace/gh-pr-num.txt
120-
121118
- run:
122119
name: Verify Github pull-request number
123120
command: |
@@ -132,7 +129,6 @@ commands:
132129
exit 1
133130
fi
134131
fi
135-
136132
jobs:
137133
# Init bits & bobs subsequent jobs require
138134
init:
@@ -150,15 +146,13 @@ jobs:
150146
command: |
151147
gh api /repos/salesforce-ux/design-system-internal/deployments --field ref=${CIRCLE_SHA1} --method GET | jq "map({ status: .statuses_url, url: .payload.web_url})" > workspace/gh-deployments.json
152148
cat workspace/gh-deployments.json
153-
154149
- run:
155150
name: Set Github deployments to "in progress"
156151
command: |
157152
for row in $(jq -r '.[] | @base64' workspace/gh-deployments.json); do
158153
export STATUS_URL=$(echo ${row} | base64 --decode | jq -r ".status" | sed 's/https:\/\/api.github.com//')
159154
gh api ${STATUS_URL} -f state=in_progress -H "Accept: application/vnd.github.flash-preview+json"
160155
done
161-
162156
- persist_to_workspace:
163157
root: workspace
164158
paths:
@@ -245,7 +239,6 @@ jobs:
245239
command: |
246240
tar -cvf workspace/design-system-dist.tar .dist/
247241
cd .dist && zip -r dist . && mv dist.zip ../workspace/ && cd ..
248-
249242
- persist_to_workspace:
250243
root: workspace
251244
paths:
@@ -270,9 +263,7 @@ jobs:
270263
command: |
271264
export VERSION_FROM_TAG=$([[ ${CIRCLE_TAG} =~ ^v.* ]] && echo ${CIRCLE_TAG:1:20} || echo ${CIRCLE_TAG})
272265
export VERSION_FROM_PACKAGE=$(cat package.json | jq -r .version)
273-
274266
gh release view v${VERSION_FROM_TAG} | grep v${VERSION_FROM_TAG}
275-
276267
if [ $? -eq 0 ]; then
277268
cp workspace/dist.zip workspace/slds-v${VERSION_FROM_TAG}.zip
278269
echo "=============================="
@@ -282,7 +273,6 @@ jobs:
282273
echo "=============================="
283274
echo "» ERROR: release v${VERSION_FROM_TAG} not found on Github"
284275
fi
285-
286276
- run:
287277
name: Trigger database update via API
288278
command: |
@@ -295,75 +285,6 @@ jobs:
295285
"salesforce_version": "'"$SALESFORCE_VERSION"'"
296286
}'
297287
298-
# Build & publish SLDS site (review app or upcoming/core-main/core-patch)
299-
publish-site:
300-
executor: slds-executor
301-
resource_class: medium
302-
303-
steps:
304-
- add_ssh_keys:
305-
fingerprints:
306-
- "20:aa:56:b6:f4:c9:f7:b9:9e:04:24:61:0c:b0:80:65"
307-
308-
- run:
309-
name: Checkout design-system-site
310-
command: |
311-
mkdir -p ~/.ssh
312-
ssh-keyscan github.com >> ~/.ssh/known_hosts
313-
git clone [email protected]:salesforce-ux/design-system-site.git .
314-
315-
- attach_workspace:
316-
at: workspace
317-
318-
- run:
319-
name: 'Decompress SLDS .dist'
320-
command: |
321-
mkdir -p .slds
322-
tar -xvf workspace/design-system-dist.tar --directory .slds
323-
324-
- node/install-npm
325-
- node/install-packages:
326-
# version cache here to remove conflict between this job and other concurrent jobs (init, prepare, etc).
327-
cache-version: standard
328-
329-
# Heroku
330-
- heroku/install
331-
- run:
332-
name: 'Install Heroku Build CLI plugin'
333-
command: 'heroku plugins:install heroku-builds'
334-
335-
- run:
336-
name: 'Build static site'
337-
command: 'npm run build'
338-
environment:
339-
SLDS__FRAMEWORK__PATH: .slds/.dist/
340-
NODE_OPTIONS: --openssl-legacy-provider
341-
342-
- run:
343-
name: 'Generate site tarball'
344-
command: |
345-
tar -czvf site-next.tar.gz .www/ Procfile config/nginx.conf.erb heroku-start.sh app.json
346-
347-
- run:
348-
name: 'Deploy to Heroku app'
349-
command: |
350-
export HEROKU_APP_NAME=$(cat workspace/heroku-app-name.txt)
351-
echo "=============================="
352-
echo ${HEROKU_APP_NAME}
353-
echo "=============================="
354-
heroku buildpacks -a ${HEROKU_APP_NAME} | grep "https://github.com/salesforce-ux/heroku-buildpack-nginx.git#dse" || heroku buildpacks:set https://github.com/salesforce-ux/heroku-buildpack-nginx.git#dse -a ${HEROKU_APP_NAME}
355-
heroku builds:create --source-tar site-next.tar.gz -a ${HEROKU_APP_NAME}
356-
357-
- gh/install
358-
- run:
359-
name: Set Github deployments to "success"
360-
command: |
361-
for row in $(jq -r '.[] | select(.url | contains("review-site")) | @base64' workspace/gh-deployments.json); do
362-
export STATUS_URL=$(echo ${row} | base64 --decode | jq -r ".status" | sed 's/https:\/\/api.github.com//')
363-
export SITE_URL=$(echo ${row} | base64 --decode | jq -r ".url")
364-
gh api ${STATUS_URL} -f state=success -f environment_url=${SITE_URL} -H "Accept: application/vnd.github.ant-man-preview+json"
365-
done
366-
367288
workflows:
368289
version: 2
369290
CI:
@@ -387,13 +308,6 @@ workflows:
387308
filters:
388309
tags:
389310
only: /.*/
390-
- publish-site:
391-
context: ux-eng-keys
392-
requires:
393-
- framework-build
394-
filters:
395-
tags:
396-
only: /.*/
397311
- populate-database:
398312
context: ux-eng-keys
399313
requires:

.github/workflows/storybook.yml

Lines changed: 116 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Make Storybook
1+
name: Make Review Apps
22

33
on: pull_request
44

@@ -209,4 +209,118 @@ jobs:
209209
export STATUS_URL=$(echo ${row} | base64 --decode | jq -r ".status" | sed 's/https:\/\/api.github.com//')
210210
export SITE_URL=$(echo ${row} | base64 --decode | jq -r ".url")
211211
gh api ${STATUS_URL} -f state=success -f environment_url=${SITE_URL} -H "Accept: application/vnd.github.ant-man-preview+json"
212-
done
212+
done
213+
214+
framework-build:
215+
# if: ${{ (1 < 0) }}
216+
runs-on: ubuntu-latest
217+
needs:
218+
- prepare
219+
220+
steps:
221+
- uses: actions/checkout@v2
222+
223+
- uses: actions/setup-node@v3
224+
with:
225+
cache: 'npm'
226+
227+
- uses: actions/download-artifact@v2
228+
with:
229+
path: workspace
230+
231+
- name: Display structure of downloaded files
232+
run: ls -R
233+
working-directory: workspace
234+
235+
- uses: "./.github/actions/copy-tokens-from-workspace"
236+
- name: Decompress styles
237+
run: tar -xvf workspace/artifact/styles.tar
238+
- name: Decompress metadata
239+
run: tar -xvf workspace/artifact/metadata.tar
240+
241+
- run: npm ci
242+
- name: Do build-dist
243+
run: npm run build-dist
244+
- name: Compress .dist
245+
run: |-
246+
tar -cvf workspace/design-system-dist.tar .dist/
247+
cd .dist && zip -r dist . && mv dist.zip ../workspace/ && cd ..
248+
- uses: actions/upload-artifact@v2
249+
with:
250+
path: |-
251+
workspace/design-system-dist.tar
252+
workspace/dist.zip
253+
254+
publish-site:
255+
runs-on: ubuntu-latest
256+
needs:
257+
- framework-build
258+
259+
steps:
260+
- uses: tibdex/github-app-token@v1
261+
id: get_installation_token
262+
with:
263+
app_id: 244972
264+
private_key: ${{ secrets.DSE_CI_APP_KEY }}
265+
266+
- name: Checkout design-system-site
267+
uses: actions/checkout@v2
268+
with:
269+
repository: salesforce-ux/design-system-site
270+
ref: main
271+
token: ${{ steps.get_installation_token.outputs.token }}
272+
273+
- name: Display structure of downloaded files
274+
run: ls -la
275+
276+
- uses: actions/download-artifact@v2
277+
with:
278+
path: workspace
279+
280+
- name: Display structure of downloaded files
281+
run: ls -R
282+
working-directory: workspace
283+
284+
- name: Decompress SLDS .dist
285+
run: |-
286+
mkdir -p .slds
287+
tar -xvf workspace/artifact/design-system-dist.tar --directory .slds
288+
289+
- uses: actions/setup-node@v3
290+
with:
291+
cache: 'npm'
292+
- run: npm ci
293+
- shell: bash
294+
run: |-
295+
if [[ $(command -v heroku) == "" ]]; then
296+
curl https://cli-assets.heroku.com/install.sh | sh
297+
else
298+
echo "Heroku is already installed. No operation was performed."
299+
fi
300+
- name: Install Heroku Build CLI plugin
301+
run: heroku plugins:install heroku-builds
302+
- name: Build static site
303+
run: npm run build
304+
env:
305+
SLDS__FRAMEWORK__PATH: ".slds/.dist/"
306+
- name: Display structure of downloaded files
307+
run: ls -la
308+
- name: Generate site tarball
309+
run: tar -czvf site-next.tar.gz .www/ Procfile config/nginx.conf.erb heroku-start.sh app.json
310+
- name: Deploy to Heroku app
311+
run: |-
312+
export HEROKU_APP_NAME=$(cat workspace/artifact/heroku-app-name.txt)
313+
echo "=============================="
314+
echo ${HEROKU_APP_NAME}
315+
echo "=============================="
316+
heroku buildpacks -a ${HEROKU_APP_NAME} | grep "https://github.com/salesforce-ux/heroku-buildpack-nginx.git#dse" || heroku buildpacks:set https://github.com/salesforce-ux/heroku-buildpack-nginx.git#dse -a ${HEROKU_APP_NAME}
317+
heroku builds:create --source-tar site-next.tar.gz -a ${HEROKU_APP_NAME}
318+
- name: Set Github deployments to "success"
319+
env:
320+
GITHUB_TOKEN: ${{ steps.get_installation_token.outputs.token }}
321+
run: |-
322+
for row in $(jq -r '.[] | select(.url | contains("review-site")) | @base64' workspace/gh-deployments.json); do
323+
export STATUS_URL=$(echo ${row} | base64 --decode | jq -r ".status" | sed 's/https:\/\/api.github.com//')
324+
export SITE_URL=$(echo ${row} | base64 --decode | jq -r ".url")
325+
gh api ${STATUS_URL} -f state=success -f environment_url=${SITE_URL} -H "Accept: application/vnd.github.ant-man-preview+json"
326+
done

0 commit comments

Comments
 (0)