-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (77 loc) · 2.5 KB
/
fe-cd-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
name: FE CD storybook
on:
pull_request:
branches:
- develop
paths:
- "frontend/**"
jobs:
build-and-deploy:
defaults:
run:
working-directory: frontend
runs-on: ubuntu-latest
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: frontend/package-lock.json
- name: Install Dependencies
run: npm install
- name: Cache node_modules
id: cache
uses: actions/cache@v3
with:
path: "**/node_modules"
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: generate environment variables
run: |
echo "API_BASE_URL=$API_BASE_URL" >> .env
env:
API_BASE_URL: ${{ secrets.API_BASE_URL }}
- name: build storybook
run: npm run build:storybook
- name: upload storybook
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.TOKEN }}
publish_dir: ./frontend/storybook-static
destination_dir: storybook
- name: add storybook url in PR description
uses: actions/github-script@v7
with:
github-token: ${{ secrets.TOKEN }}
script: |
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});
const body = pr.data.body;
const storybookUrl = "## 🌸 Storybook 배포 주소 \n\n> https://woowacourse-teams.github.io/2024-ddangkong/storybook/";
if (body.includes(storybookUrl)) {
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
body: body
});
} else {
const newBody = body + "\n\n" + storybookUrl;
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
body: newBody
});
}