Skip to content

Commit d843464

Browse files
snomiaoclaude
andcommitted
[feat] Implement workflow_run for both start and completion events
- Updated pr-playwright-comment.yaml to trigger on both 'requested' and 'completed' events - Updated pr-storybook-comment.yaml to trigger on both 'requested' and 'completed' events - Added conditional logic to post different messages for workflow start vs completion - Added "Tests are starting..." message when workflows begin - Added "Build is starting..." message for Storybook builds - Maintained existing completion logic with full test results and reports This allows users to see immediate feedback when their workflows start running, improving the user experience by providing real-time status updates. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent b370e34 commit d843464

File tree

2 files changed

+65
-9
lines changed

2 files changed

+65
-9
lines changed

.github/workflows/pr-playwright-comment.yaml

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: PR Playwright Comment
33
on:
44
workflow_run:
55
workflows: ["Tests CI"]
6-
types: [completed]
6+
types: [requested, completed]
77

88
env:
99
DATE_FORMAT: '+%m/%d/%Y, %I:%M:%S %p'
@@ -36,7 +36,7 @@ jobs:
3636
return pullRequests[0].number;
3737
3838
- name: Download all deployment info
39-
if: steps.pr.outputs.result != 'null'
39+
if: steps.pr.outputs.result != 'null' && github.event.action == 'completed'
4040
uses: actions/download-artifact@v4
4141
with:
4242
github-token: ${{ secrets.GITHUB_TOKEN }}
@@ -49,9 +49,29 @@ jobs:
4949
id: completion-time
5050
run: echo "time=$(date -u '${{ env.DATE_FORMAT }}')" >> $GITHUB_OUTPUT
5151

52-
- name: Generate comment body
53-
if: steps.pr.outputs.result != 'null'
54-
id: comment-body
52+
- name: Generate comment body for start
53+
if: steps.pr.outputs.result != 'null' && github.event.action == 'requested'
54+
id: comment-body-start
55+
run: |
56+
echo "<!-- PLAYWRIGHT_TEST_STATUS -->" > comment.md
57+
echo "## 🎭 Playwright Test Results" >> comment.md
58+
echo "" >> comment.md
59+
echo "⏳ **Tests are starting...** " >> comment.md
60+
echo "" >> comment.md
61+
echo "⏰ Started at: ${{ steps.completion-time.outputs.time }} UTC" >> comment.md
62+
echo "" >> comment.md
63+
echo "### 🚀 Running Tests" >> comment.md
64+
echo "- 🧪 **chromium**: Running tests..." >> comment.md
65+
echo "- 🧪 **chromium-0.5x**: Running tests..." >> comment.md
66+
echo "- 🧪 **chromium-2x**: Running tests..." >> comment.md
67+
echo "- 🧪 **mobile-chrome**: Running tests..." >> comment.md
68+
echo "" >> comment.md
69+
echo "---" >> comment.md
70+
echo "⏱️ Please wait while tests are running across all browsers..." >> comment.md
71+
72+
- name: Generate comment body for completion
73+
if: steps.pr.outputs.result != 'null' && github.event.action == 'completed'
74+
id: comment-body-completed
5575
run: |
5676
echo "<!-- PLAYWRIGHT_TEST_STATUS -->" > comment.md
5777
echo "## 🎭 Playwright Test Results" >> comment.md
@@ -107,8 +127,19 @@ jobs:
107127
echo "⚠️ Please check the test reports for details on failures." >> comment.md
108128
fi
109129
130+
- name: Comment PR - Tests Started
131+
if: steps.pr.outputs.result != 'null' && github.event.action == 'requested'
132+
continue-on-error: true
133+
uses: edumserrano/find-create-or-update-comment@v3
134+
with:
135+
issue-number: ${{ steps.pr.outputs.result }}
136+
body-includes: '<!-- PLAYWRIGHT_TEST_STATUS -->'
137+
comment-author: 'github-actions[bot]'
138+
edit-mode: replace
139+
body-path: comment.md
140+
110141
- name: Comment PR - Tests Complete
111-
if: steps.pr.outputs.result != 'null'
142+
if: steps.pr.outputs.result != 'null' && github.event.action == 'completed'
112143
continue-on-error: true
113144
uses: edumserrano/find-create-or-update-comment@v3
114145
with:

.github/workflows/pr-storybook-comment.yaml

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: PR Storybook Comment
33
on:
44
workflow_run:
55
workflows: ["Chromatic"]
6-
types: [completed]
6+
types: [requested, completed]
77

88
jobs:
99
comment-storybook:
@@ -33,7 +33,7 @@ jobs:
3333
return pullRequests[0].number;
3434
3535
- name: Get workflow run details
36-
if: steps.pr.outputs.result != 'null'
36+
if: steps.pr.outputs.result != 'null' && github.event.action == 'completed'
3737
id: workflow-run
3838
uses: actions/github-script@v7
3939
with:
@@ -53,8 +53,33 @@ jobs:
5353
id: completion-time
5454
run: echo "time=$(date -u '+%m/%d/%Y, %I:%M:%S %p')" >> $GITHUB_OUTPUT
5555

56+
- name: Comment PR - Storybook Started
57+
if: steps.pr.outputs.result != 'null' && github.event.action == 'requested'
58+
continue-on-error: true
59+
uses: edumserrano/find-create-or-update-comment@v3
60+
with:
61+
issue-number: ${{ steps.pr.outputs.result }}
62+
body-includes: '<!-- STORYBOOK_BUILD_STATUS -->'
63+
comment-author: 'github-actions[bot]'
64+
edit-mode: replace
65+
body: |
66+
<!-- STORYBOOK_BUILD_STATUS -->
67+
## 🎨 Storybook Build Status
68+
69+
⏳ **Build is starting...**
70+
71+
⏰ Started at: ${{ steps.completion-time.outputs.time }} UTC
72+
73+
### 🚀 Building Storybook
74+
- 📦 Installing dependencies...
75+
- 🔧 Building Storybook components...
76+
- 🎨 Running Chromatic visual tests...
77+
78+
---
79+
⏱️ Please wait while the Storybook build is in progress...
80+
5681
- name: Comment PR - Storybook Complete
57-
if: steps.pr.outputs.result != 'null'
82+
if: steps.pr.outputs.result != 'null' && github.event.action == 'completed'
5883
continue-on-error: true
5984
uses: edumserrano/find-create-or-update-comment@v3
6085
with:

0 commit comments

Comments
 (0)