Skip to content

Commit 549ebde

Browse files
authored
ci: update VRT workflow (#105)
1 parent 20072df commit 549ebde

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

.github/workflows/vrt.yml

+31-9
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,26 @@ on:
33
issue_comment:
44
types: [created]
55
jobs:
6-
vrt:
7-
# Trigger by PullRequest comments
6+
chromatic:
87
if: ${{ github.event.issue.pull_request && github.event.comment.body == '/vrt' }}
98
runs-on: ubuntu-latest
9+
permissions:
10+
pull-requests: write
11+
statuses: write
1012
steps:
11-
- name: Get PR details
13+
- name: Set pending status
1214
uses: actions/github-script@v7
13-
id: get-pr
1415
with:
1516
script: |
1617
const { owner, repo } = context.repo;
17-
const pr = await github.rest.pulls.get({
18-
owner,
19-
repo,
20-
pull_number: context.issue.number
18+
await github.rest.repos.createCommitStatus({
19+
owner,
20+
repo,
21+
sha: context.sha,
22+
state: 'pending',
23+
context: 'VRT',
24+
description: 'VRT is running'
2125
});
22-
return pr.data;
2326
- name: Checkout repository
2427
uses: actions/checkout@v4
2528
with:
@@ -33,6 +36,25 @@ jobs:
3336
- name: Install dependencies
3437
run: npm ci
3538
- name: Publish to Chromatic
39+
id: chromatic
3640
uses: chromaui/action@latest
3741
with:
3842
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
43+
workingDir: packages/storybook
44+
buildScriptName: build-storybook
45+
- name: Update status
46+
if: always()
47+
uses: actions/github-script@v7
48+
with:
49+
script: |-
50+
const { owner, repo } = context.repo;
51+
await github.rest.repos.createCommitStatus({
52+
owner,
53+
repo,
54+
sha: context.sha,
55+
state: '${{ steps.chromatic.outcome }}' === 'success' ? 'success' : 'failure',
56+
context: 'Chromatic',
57+
description: '${{ steps.chromatic.outcome }}' === 'success'
58+
? 'VRT passed'
59+
: 'VRT failed'
60+
});

0 commit comments

Comments
 (0)