-
Notifications
You must be signed in to change notification settings - Fork 7
92 lines (86 loc) · 3.16 KB
/
chromatic.yml
File metadata and controls
92 lines (86 loc) · 3.16 KB
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
name: "Chromatic"
permissions:
contents: read
on:
push:
branches:
- master # Workflow runs on pushes to the main branch
pull_request:
types: [opened, reopened, synchronize]
jobs:
pr-chromatic:
runs-on: ubuntu-22.04
strategy:
matrix:
node-version: [22.18.0]
if: >
${{ github.event_name == 'pull_request' && contains(github.event.pull_request.title, '[run-chromatic]') }}
steps:
- name: Check if actor is repo admin
id: permission
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN}}
ACTOR: ${{ github.actor }}
REPO: ${{ github.repository }}
run: |
PERMISSION=$(curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GH_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$REPO/collaborators/$ACTOR/permission \
| jq -r '.permission')
echo "Actor permission: $PERMISSION"
if [[ "$PERMISSION" != "admin" ]]; then
echo "❌ Actor is not an admin"
exit 1
fi
echo "✅ Actor is admin"
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
env:
CHROMATIC_BRANCH: ${{ github.event.pull_request.head.ref || github.ref_name }}
CHROMATIC_SHA: ${{ github.event.pull_request.head.sha || github.ref }}
CHROMATIC_SLUG: ${{ github.repository }}
- name: Verify checkout
run: |
echo ">>>>GitHub Event Pull Request Head SHA: ${{ github.event.pull_request.head.ref }}"
echo ">>>>Checked out commit: $(git rev-parse HEAD)"
- uses: pnpm/action-setup@v4
- name: Install dependencies
# ⚠️ See your package manager's documentation for the correct command to install dependencies in a CI
run: pnpm install
- name: Run Chromatic
uses: chromaui/action@latest
with:
# ⚠️ Make sure to configure a `CHROMATIC_PROJECT_TOKEN` repository secret
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
onlyChanged: true
exitZeroOnChanges: false
skip: "dependabot/**"
master-chromatic:
runs-on: ubuntu-22.04
strategy:
matrix:
node-version: [22.18.0]
if: >
${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && contains(github.event.head_commit.message, '[run-chromatic]') }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v4
- name: Install dependencies
# ⚠️ See your package manager's documentation for the correct command to install dependencies in a CI environment.
run: pnpm install
- name: Run Chromatic
uses: chromaui/action@latest
with:
# ⚠️ Make sure to configure a `CHROMATIC_PROJECT_TOKEN` repository secret
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
onlyChanged: true
exitZeroOnChanges: false
skip: "dependabot/**"