Skip to content

Commit aa7dcb1

Browse files
committed
chore: only comment on canary label
1 parent ea759f0 commit aa7dcb1

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

.github/workflows/canary-comment.yml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,30 @@ jobs:
3535
3636
if (prs.data.length > 0) {
3737
const pr = prs.data[0];
38-
core.setOutput('pr_number', pr.number);
39-
core.setOutput('found', 'true');
40-
console.log(`Found PR #${pr.number}`);
38+
39+
// Check if PR has the deploy-canary label
40+
const labels = pr.labels.map(label => label.name);
41+
const hasCanaryLabel = labels.includes('deploy-canary');
42+
43+
if (hasCanaryLabel) {
44+
core.setOutput('pr_number', pr.number);
45+
core.setOutput('found', 'true');
46+
core.setOutput('has_canary_label', 'true');
47+
console.log(`Found PR #${pr.number} with deploy-canary label`);
48+
} else {
49+
core.setOutput('found', 'false');
50+
core.setOutput('has_canary_label', 'false');
51+
console.log(`Found PR #${pr.number} but it doesn't have deploy-canary label`);
52+
}
4153
} else {
4254
core.setOutput('found', 'false');
55+
core.setOutput('has_canary_label', 'false');
4356
console.log('No associated PR found');
4457
}
4558
4659
# Extract canary info from the workflow run
4760
- name: Extract canary info
48-
if: ${{ steps.pr-info.outputs.found == 'true' && github.event.workflow_run.conclusion == 'success' }}
61+
if: ${{ steps.pr-info.outputs.found == 'true' && steps.pr-info.outputs.has_canary_label == 'true' && github.event.workflow_run.conclusion == 'success' }}
4962
id: canary-info
5063
uses: actions/github-script@v7
5164
with:
@@ -67,7 +80,7 @@ jobs:
6780
6881
# Find existing comment
6982
- name: Find existing comment
70-
if: ${{ steps.pr-info.outputs.found == 'true' }}
83+
if: ${{ steps.pr-info.outputs.found == 'true' && steps.pr-info.outputs.has_canary_label == 'true' }}
7184
uses: peter-evans/find-comment@v3
7285
id: find-comment
7386
with:
@@ -77,7 +90,7 @@ jobs:
7790

7891
# Create or update comment based on workflow status
7992
- name: Create or update canary comment
80-
if: ${{ steps.pr-info.outputs.found == 'true' }}
93+
if: ${{ steps.pr-info.outputs.found == 'true' && steps.pr-info.outputs.has_canary_label == 'true' }}
8194
uses: peter-evans/create-or-update-comment@v4
8295
with:
8396
comment-id: ${{ steps.find-comment.outputs.comment-id }}

0 commit comments

Comments
 (0)