-
Notifications
You must be signed in to change notification settings - Fork 69
104 lines (86 loc) · 3.22 KB
/
storybook-deploy.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
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
#
# OpenCRVS is also distributed under the terms of the Civil Registration
# & Healthcare Disclaimer located at http://opencrvs.org/license.
#
# Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
name: Build and Deploy Storybook to Cloudflare Pages
on:
push:
branches:
- master
- develop
- release-v*
issue_comment:
types:
- created
jobs:
build:
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
repository: 'opencrvs/opencrvs-core'
ref: ${{ github.ref }}
- name: Set up Node.js
uses: actions/setup-node@v3
with:
cache: 'yarn'
- name: Install dependencies
run: yarn install
- name: Build components
run: cd packages/components && yarn build
- name: Build Storybook
run: cd packages/components && yarn build-storybook
- name: Deploy
run: npx wrangler pages deploy ./packages/components/build --project-name opencrvs --branch ${{ github.ref_name }}
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
comment-check:
if: github.event_name == 'issue_comment' && github.event.comment.body == '/uikit'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
repository: 'opencrvs/opencrvs-core'
- name: Get the PR branch name
id: get_branch
run: |
echo "PR_BRANCH=$(gh pr view ${{ github.event.issue.number }} --json headRefName --jq .headRefName)" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.OLLIE_BOT_GITHUB_TOKEN }}
- name: Checkout PR branch
uses: actions/checkout@v3
with:
repository: 'opencrvs/opencrvs-core'
ref: ${{ env.PR_BRANCH }}
- name: Set up Node.js
uses: actions/setup-node@v3
with:
cache: 'yarn'
- name: Install dependencies
run: yarn install
- name: Build components
run: cd packages/components && yarn build
- name: Build Storybook
run: cd packages/components && yarn build-storybook
- name: Deploy Storybook to Cloudflare Pages
id: deploy_storybook
run: |
DEPLOY_OUTPUT=$(npx wrangler pages deploy ./packages/components/build --project-name opencrvs --branch ${{ env.PR_BRANCH }})
echo "$DEPLOY_OUTPUT"
DEPLOY_URL=$(echo "$DEPLOY_OUTPUT" | grep -o 'https://.*.dev' | tail -n 1)
echo "storybook_url=$DEPLOY_URL" >> $GITHUB_OUTPUT
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
- name: Comment on PR with Storybook link
run: |
COMMENT="Storybook deployed: ${{ steps.deploy_storybook.outputs.storybook_url }}"
gh pr comment ${{ github.event.issue.number }} --body "$COMMENT"
env:
GITHUB_TOKEN: ${{ secrets.OLLIE_BOT_GITHUB_TOKEN }}