-
Notifications
You must be signed in to change notification settings - Fork 16
93 lines (70 loc) · 2.89 KB
/
pr-build.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
name: PR Build
on:
pull_request:
branches:
- '*'
permissions:
contents: write
pull-requests: write
repository-projects: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install Dependencies 📦
run: yarn install
- name: Lint 🧼
run: yarn lint
- name: Test 🧪
run: yarn test
- name: SonarCloud 🔬
uses: sonarsource/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Build 🛠️
run: yarn build
- name: Build Storybook
run: yarn build:storybook
- name: Create and Upload Storybook to PR directory
run: |
PR_NUMBER="PR-${{ github.event.number }}"
git config user.name "evargast"
git config user.email "[email protected]"
# Fetch the existing gh-pages branch
git fetch origin gh-pages
# Checkout the existing gh-pages branch
git checkout gh-pages
# Remove the PR directory if it exists
rm -rf "${PR_NUMBER}"
# Create the PR directory
mkdir "${PR_NUMBER}"
# Copy the contents of dist-storybook to the directory
cp -r dist-storybook/* "${PR_NUMBER}/"
rm -rf node_modules # Explicitly remove the node_modules directory
rm -rf dist-storybook # Explicitly remove the dist-storybook directory
# Add, commit, and push changes
git add "${PR_NUMBER}/."
git commit -m "Update Storybook for ${PR_NUMBER}"
git push -f origin gh-pages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Add comment to the PR with Storybook URL
run: |
PR_NUMBER="${{ github.event.number }}"
COMMENT_BODY="🎨 Storybook -> https://opensource.adobe.com/react-spectrum-charts/PR-${PR_NUMBER}"
curl -sSL \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-X POST \
-d '{"body":"'"${COMMENT_BODY}"'"}' \
"https://api.github.com/repos/${{ github.repository }}/issues/${PR_NUMBER}/comments"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}