-
Notifications
You must be signed in to change notification settings - Fork 152
89 lines (74 loc) · 2.71 KB
/
storybook.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
name: Storybook
on:
push:
branches:
- master
pull_request:
branches:
- "**"
env: # Set environment variables for every job and step in this workflow
CLICOLOR: "1" # Enable colors for *NIX commands
PY_COLORS: "1" # Enable colors for Python-based utilities
FORCE_COLOR: "1" # Force colors in the terminal
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
pull-requests: write # for dependabot
contents: write # for deploying to GitHub Pages on master
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Node
uses: ./.github/actions/node
- name: Compile design tokens
run: yarn tokens build
- name: Build tailwind
run: yarn tailwind-preset build
- name: Build Storybook
run: yarn components build:storybook
- name: Get BRANCH_URL
# do not run on master branch
if: github.ref != 'refs/heads/master'
env:
BRANCH_NAME: ${{ github.head_ref }}
run: echo "BRANCH_URL=$(sed -e 's/[^a-zA-Z0-9]/-/g' <<< ${BRANCH_NAME})" >> $GITHUB_ENV
- name: Get DOMAIN
if: github.ref != 'refs/heads/master'
run: echo "DOMAIN=https://kiwicom-orbit-${BRANCH_URL}.surge.sh" >> $GITHUB_ENV
- name: Deploy to staging
if: github.ref != 'refs/heads/master'
run: yarn components deploy:surge ${DOMAIN} --token ${{ secrets.SURGE_TOKEN }}
- name: Add comment to PR
if: github.ref != 'refs/heads/master'
uses: actions/github-script@v6
with:
script: |
const commentBody = `Storybook staging is available at ${process.env.DOMAIN}`;
const commentsList = await github.rest.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
});
const comment = commentsList.data.find((comment) => comment.body.includes(commentBody));
if (!comment) {
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody,
})
} else {
github.rest.issues.updateComment({
comment_id: comment.id,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody,
})
}
- name: Deploy to production
# run on master branch
if: github.ref == 'refs/heads/master'
run: yarn components deploy:storybook --ci
env:
GH_TOKEN: ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}