-
-
Notifications
You must be signed in to change notification settings - Fork 28
111 lines (97 loc) · 3 KB
/
ui.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
105
106
107
108
109
110
111
name: UI
on:
pull_request:
push:
branches:
- main
env:
DIST_PATH: "ui/storybook-static"
PR_NUMBER: ${{ github.event.number }}
jobs:
check_applicability:
name: Check applicability
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
paths: '["ui/**", "package-lock.json", ".github/workflows/ui.yml"]'
skip_after_successful_duplicate: "false"
build:
name: Build UI
runs-on: ubuntu-latest
needs: check_applicability
if: needs.check_applicability.outputs.should_skip != 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Initialize repository
uses: ./.github/workflows/actions/init
- name: Set Storybook env variables
run: |
echo "$PR_NUMBER"
if [[ $PR_NUMBER ]]; then
echo 'STORYBOOK_PATH_PREFIX=/public/pr-preview/pr-${{ github.event.number }}/' >>"$GITHUB_ENV"
else
echo "STORYBOOK_PATH_PREFIX=/public/" >>"$GITHUB_ENV"
fi
- name: Build UI documentation
run: npm run ui:build
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: storybook-static
path: "${{ env.DIST_PATH }}/"
if-no-files-found: error
retention-days: 1
deploy-preview:
name: Deploy UI preview
runs-on: ubuntu-latest
if: github.event.number # only run on PRs
concurrency: ui-preview-deployment-${{ github.ref }}
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: storybook-static
path: ${{ env.DIST_PATH }}
- name: Deploy preview to GitHub Pages
uses: rossjrw/pr-preview-action@v1
with:
source-dir: ${{ env.DIST_PATH }}
preview-branch: gh-pages
umbrella-dir: pr-preview
action: auto
deploy-main:
name: Deploy UI
runs-on: ubuntu-latest
concurrency: ui-deployment-main
if: github.ref == 'refs/heads/main'
needs: build
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
contents: write
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: storybook-static
path: ${{ env.DIST_PATH }}
- name: Deploy on GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: ${{ env.DIST_PATH }}
clean-exclude: pr-preview
force: false
branch: gh-pages