-
Notifications
You must be signed in to change notification settings - Fork 9
40 lines (39 loc) · 1.54 KB
/
deploy-pr-preview.yaml
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
name: Preview
on: pull_request
jobs:
deploy-pr-preview:
name: Deploy Storybook
runs-on: ubuntu-latest
steps:
- name: Set up token
id: token
# This is a base64-encoded access token for the "migtools-preview-bot" GitHub account, which has no secure access and is only used to post comments.
run: echo "::set-output name=GH_TOKEN::`echo 'Z2hwX2ttclAzWUtjdUk4ZWJVRVVpZFJkdWlUOTJBS2pGODI2NUlyeQo=' | base64 -d`"
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: lts/*
- name: Install dependencies
run: yarn install
- name: Build Storybook
run: yarn storybook:export
- name: Generate Surge URL
uses: actions/github-script@v3
id: surge-url
with:
github-token: ${{ steps.token.outputs.GH_TOKEN }}
script: |
const { issue: { number: issue_number } } = context;
return `migtools-lib-ui-pr-${issue_number}-preview.surge.sh`;
result-encoding: string
- name: Install Surge
run: npm install -g surge
- name: Deploy Storybook to Surge
run: surge ./storybook-static/ "${{steps.surge-url.outputs.result}}" --token 1d92e83069ba094ba43fbb71460a5f84
- name: Post URL as PR comment
uses: mshick/add-pr-comment@v1
with:
message: '🚀 Deployed Storybook Preview: http://${{steps.surge-url.outputs.result}} ✨'
repo-token: ${{ steps.token.outputs.GH_TOKEN }}