Skip to content

Commit 8a3857f

Browse files
authored
feat(ci): Migrate Storybook CircleCI jobs to GH Actions (#5102)
* clean up vrt bits from CircleCI config * make init and prepare jobs * make build-storybook job * make publish-storybook job * remove storybook jobs from CircleCI config * fix deployments step
1 parent 26b14c0 commit 8a3857f

File tree

6 files changed

+297
-171
lines changed

6 files changed

+297
-171
lines changed

.circleci/config.yml

Lines changed: 1 addition & 171 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,6 @@
44
#
55
version: 2.1
66

7-
parameters:
8-
run_labeled_workflow:
9-
type: boolean
10-
default: false
11-
triggering_label:
12-
type: string
13-
default: ""
14-
vrt_mode:
15-
type: string
16-
default: ""
17-
187
orbs:
198
node: circleci/[email protected]
209
heroku: circleci/[email protected]
@@ -107,57 +96,6 @@ commands:
10796
echo "=============================="
10897
echo
10998
110-
prepare-vrt:
111-
description: 'Prepare VRT environment'
112-
steps:
113-
- checkout
114-
115-
- attach_workspace:
116-
at: workspace
117-
118-
- node/install-npm
119-
- vrt-set-env-vars
120-
- add-applitools
121-
- node/install-packages
122-
- browser-tools/install-chrome
123-
- browser-tools/install-chromedriver
124-
125-
- run:
126-
name: 'Prepare Storybook'
127-
command: 'npm run storybook:prepare'
128-
129-
vrt-set-env-vars:
130-
description: 'Set VRT environment variables'
131-
steps:
132-
- set-github-pr-number
133-
- run: printenv | sort
134-
135-
- run:
136-
name: 'Set environment variables'
137-
command: |
138-
echo 'export APPLITOOLS_BATCH_ID=${CIRCLE_SHA1}' >> $BASH_ENV
139-
echo 'export APPLITOOLS_BATCH_NAME="PR #${PR_NUMBER} (${CIRCLE_USERNAME})"' >> $BASH_ENV
140-
echo 'export APPLITOOLS_DONT_CLOSE_BATCHES="true"' >> $BASH_ENV
141-
echo 'export APPLITOOLS_BATCH_NOTIFY="true"' >> $BASH_ENV
142-
echo 'export REVIEW_APP_NAME=slds-storybook-pr-${PR_NUMBER}' >> $BASH_ENV
143-
144-
vrt-close-batch:
145-
description: 'Notify Applitools that tests have completed'
146-
steps:
147-
- run:
148-
name: 'Applitools: close batch'
149-
command: |
150-
export GITHUB_SERVER=github.com
151-
url="https://salesforceuxeyesapi.applitools.com/api/externals/github/servers/${GITHUB_SERVER}/commit/${CIRCLE_SHA1}/complete?apiKey=${APPLITOOLS_API_KEY}"
152-
curl -X POST $url -H "Content-Type: application/json" --data "{'serverId': '${GITHUB_SERVER}', 'commitSha': '${CIRCLE_SHA1}'}" -v -L
153-
154-
add-applitools:
155-
description: 'Add Applitools eyes-storybook module'
156-
steps:
157-
- run:
158-
name: Add Applitools eyes-storybook module
159-
command: 'npm i @applitools/eyes-storybook@latest --save-dev --package-lock-only'
160-
16199
get-pr-number:
162100
description: 'Get Github pull-request number'
163101
steps:
@@ -195,23 +133,6 @@ commands:
195133
fi
196134
fi
197135
198-
launch-static-storybook:
199-
description: 'Launch local static Storybook server'
200-
steps:
201-
- attach_workspace:
202-
at: workspace
203-
- run:
204-
name: Decompress Storybook archive
205-
command: 'tar -xvf workspace/storybook.tar.gz'
206-
- run:
207-
name: Start server
208-
command: 'npx http-server .www'
209-
background: true
210-
- run:
211-
name: Poll until server is up
212-
shell: /bin/sh
213-
command: 'curl --connect-timeout 2 --max-time 2 --retry 50 --retry-delay 0 --retry-max-time 300 --retry-connrefused --ipv4 -q "http://localhost:8080"'
214-
215136
jobs:
216137
# Init bits & bobs subsequent jobs require
217138
init:
@@ -228,6 +149,7 @@ jobs:
228149
name: Retrieve Github deployments
229150
command: |
230151
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
152+
cat workspace/gh-deployments.json
231153
232154
- run:
233155
name: Set Github deployments to "in progress"
@@ -373,86 +295,6 @@ jobs:
373295
"salesforce_version": "'"$SALESFORCE_VERSION"'"
374296
}'
375297
376-
# Build static Storybook
377-
build-storybook:
378-
executor: slds-executor
379-
resource_class: medium+
380-
381-
steps:
382-
- checkout
383-
- attach_workspace:
384-
at: workspace
385-
- copy-tokens-from-workspace
386-
- node/install-npm
387-
- node/install-packages:
388-
# version cache here to remove conflict between this job and other concurrent jobs (init, prepare, etc).
389-
cache-version: standard
390-
391-
- run:
392-
name: Build static Storybook
393-
command: 'npm run storybook:build'
394-
environment:
395-
NODE_OPTIONS: --openssl-legacy-provider
396-
397-
- run:
398-
name: Archive static Storybook
399-
command: 'tar -czvf workspace/storybook.tar.gz .www/ Procfile config/nginx.conf.erb heroku-start.sh app.json'
400-
401-
- persist_to_workspace:
402-
root: workspace
403-
paths:
404-
- storybook.tar.gz
405-
406-
# Publish Storybook to Heroku review app
407-
publish-storybook:
408-
executor: slds-executor
409-
resource_class: small
410-
411-
steps:
412-
- attach_workspace:
413-
at: workspace
414-
415-
- run:
416-
name: 'Only proceed if we have a Storybook app to update'
417-
command: |
418-
export HEROKU_RELEASE_STORYBOOK_APP_NAME=$(cat workspace/heroku-release-storybook-app-name.txt)
419-
if [[ ${HEROKU_RELEASE_STORYBOOK_APP_NAME} == "false" ]]; then
420-
circleci step halt
421-
fi
422-
423-
- vrt-set-env-vars
424-
425-
# Heroku
426-
- heroku/install
427-
- run:
428-
name: 'Install Heroku Build CLI plugin'
429-
command: 'heroku plugins:install heroku-builds'
430-
431-
- run:
432-
name: 'Deploy to Heroku'
433-
command: |
434-
export HEROKU_RELEASE_STORYBOOK_APP_NAME=$(cat workspace/heroku-release-storybook-app-name.txt)
435-
if [[ ${HEROKU_RELEASE_STORYBOOK_APP_NAME} != "false" && ${PR_NUMBER} == "" ]]; then
436-
export PUBLISH_STORYBOOK_TO=${HEROKU_RELEASE_STORYBOOK_APP_NAME}
437-
else
438-
export PUBLISH_STORYBOOK_TO=${REVIEW_APP_NAME}
439-
fi
440-
echo "=============================="
441-
echo ${PUBLISH_STORYBOOK_TO}
442-
echo "=============================="
443-
heroku buildpacks -a ${PUBLISH_STORYBOOK_TO} | 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 ${PUBLISH_STORYBOOK_TO}
444-
heroku builds:create --source-tar workspace/storybook.tar.gz -a ${PUBLISH_STORYBOOK_TO}
445-
446-
- gh/install
447-
- run:
448-
name: Set Github deployments to "success"
449-
command: |
450-
for row in $(jq -r '.[] | select(.url | contains("storybook")) | @base64' workspace/gh-deployments.json); do
451-
export STATUS_URL=$(echo ${row} | base64 --decode | jq -r ".status" | sed 's/https:\/\/api.github.com//')
452-
export SITE_URL=$(echo ${row} | base64 --decode | jq -r ".url")
453-
gh api ${STATUS_URL} -f state=success -f environment_url=${SITE_URL} -H "Accept: application/vnd.github.ant-man-preview+json"
454-
done
455-
456298
# Build & publish SLDS site (review app or upcoming/core-main/core-patch)
457299
publish-site:
458300
executor: slds-executor
@@ -538,18 +380,6 @@ workflows:
538380
only: /.*/
539381
requires:
540382
- init
541-
- build-storybook:
542-
context: ux-eng-keys
543-
# do not run for future version tags (X.X.X-*)
544-
filters:
545-
tags:
546-
ignore: /^v\d+\.\d+\.\d+-.+$/
547-
requires:
548-
- prepare
549-
- publish-storybook:
550-
context: ux-eng-keys
551-
requires:
552-
- build-storybook
553383
- framework-build:
554384
context: ux-eng-keys
555385
requires:
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name: build-tokens
2+
runs:
3+
using: composite
4+
steps:
5+
- name: Build Tokens
6+
run: npm run gulp -- generate:tokens:all
7+
shell: bash
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name: copy-tokens-from-workspace
2+
runs:
3+
using: composite
4+
steps:
5+
- name: Decompress design-tokens
6+
run: tar -xvf workspace/artifact/design-tokens.tar
7+
shell: bash
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name: copy-tokens-to-workspace
2+
runs:
3+
using: composite
4+
steps:
5+
- name: Compress design-tokens
6+
run: tar -cvf workspace/design-tokens.tar design-tokens/
7+
shell: bash
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: set-heroku-app-name
2+
outputs:
3+
HEROKU_APP_NAME:
4+
value: ${{ steps.which-app.outputs.HEROKU_APP_NAME }}
5+
HEROKU_RELEASE_STORYBOOK_APP_NAME:
6+
value: ${{ steps.which-app.outputs.HEROKU_RELEASE_STORYBOOK_APP_NAME }}
7+
runs:
8+
using: composite
9+
steps:
10+
- name: Set which app to deploy to on Heroku
11+
id: which-app
12+
# if on default branch without a tag
13+
# then publish to UPCOMING
14+
#
15+
# if on default branch and tag of X.X.X-*
16+
# then publish to CORE-MAIN
17+
#
18+
# if on any branch and tag of X.X.X
19+
# then publish to CORE-PATCH
20+
#
21+
# All other cases publish to the review app
22+
run: |-
23+
export CURRENT_DEFAULT_BRANCH=`git remote show origin | grep "HEAD branch" | cut -d ":" -f 2 | xargs`
24+
echo 'HEROKU_RELEASE_STORYBOOK_APP_NAME=false' >> $GITHUB_OUTPUT
25+
if [[ "${{ github.ref }}" = "${CURRENT_DEFAULT_BRANCH}" ]] ; then
26+
echo "Publishing to UPCOMING..."
27+
echo 'HEROKU_APP_NAME=${HEROKU_APP_UPCOMING}' >> $GITHUB_OUTPUT
28+
echo 'HEROKU_RELEASE_STORYBOOK_APP_NAME=storybook-upcoming' >> $GITHUB_OUTPUT
29+
elif [[ ${{ github.ref }} =~ ^v[0-9]+\.[0-9]+\.[0-9]+-.+$ ]] ; then
30+
echo "Publishing to CORE-MAIN..."
31+
echo 'HEROKU_APP_NAME=${HEROKU_APP_CORE_MAIN}' >> $GITHUB_OUTPUT
32+
echo 'HEROKU_RELEASE_STORYBOOK_APP_NAME=storybook-core-main' >> $GITHUB_OUTPUT
33+
elif [[ ${{ github.ref }} =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] ; then
34+
echo "Publishing to CORE-PATCH..."
35+
echo 'HEROKU_APP_NAME=${HEROKU_APP_CORE_PATCH}' >> $GITHUB_OUTPUT
36+
echo 'HEROKU_RELEASE_STORYBOOK_APP_NAME=storybook-core-patch' >> $GITHUB_OUTPUT
37+
else
38+
echo "Publishing to pull-request review app..."
39+
echo 'HEROKU_APP_NAME=slds-review-site-pr-${{ github.event.pull_request.number }}' >> $GITHUB_OUTPUT
40+
echo 'HEROKU_RELEASE_STORYBOOK_APP_NAME=true' >> $GITHUB_OUTPUT
41+
fi
42+
shell: bash
43+
- run: printenv | sort
44+
shell: bash
45+
- run: |-
46+
HEROKU_APP_NAME=${{ steps.which-app.outputs.HEROKU_APP_NAME }}
47+
HEROKU_RELEASE_STORYBOOK_APP_NAME=${{ steps.which-app.outputs.HEROKU_RELEASE_STORYBOOK_APP_NAME }}
48+
echo $HEROKU_APP_NAME > workspace/heroku-app-name.txt
49+
echo $HEROKU_RELEASE_STORYBOOK_APP_NAME > workspace/heroku-release-storybook-app-name.txt
50+
shell: bash
51+
- name: Show HEROKU_APP_NAME value
52+
run: |-
53+
echo
54+
echo "PR_NUMBER = ${{ github.event.pull_request.number }}"
55+
echo
56+
echo "HEROKU_APP_NAME=============================="
57+
cat workspace/heroku-app-name.txt
58+
echo "============================================="
59+
echo
60+
echo
61+
echo "HEROKU_RELEASE_STORYBOOK_APP_NAME============"
62+
cat workspace/heroku-release-storybook-app-name.txt
63+
echo "============================================="
64+
echo
65+
shell: bash

0 commit comments

Comments
 (0)