Skip to content

Commit dcb8e9b

Browse files
authored
ci: fix canary-comment dependency (#989)
* ci: fix canary-comment dependency * chore: change dependency for trigger * chore: only comment on canary label * Revert "chore: change dependency for trigger" This reverts commit ea759f0.
1 parent 8b5b74f commit dcb8e9b

File tree

2 files changed

+37
-43
lines changed

2 files changed

+37
-43
lines changed

.github/workflows/canary-comment.yml

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -35,42 +35,52 @@ 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
46-
# Only continue if we found a PR and the workflow succeeded
47-
- name: Download canary info
48-
if: ${{ steps.pr-info.outputs.found == 'true' && github.event.workflow_run.conclusion == 'success' }}
49-
uses: actions/download-artifact@v4
59+
# Extract canary info from the workflow run
60+
- name: Extract canary info
61+
if: ${{ steps.pr-info.outputs.found == 'true' && steps.pr-info.outputs.has_canary_label == 'true' && github.event.workflow_run.conclusion == 'success' }}
62+
id: canary-info
63+
uses: actions/github-script@v7
5064
with:
51-
name: canary-info
52-
path: canary-info/
53-
run-id: ${{ github.event.workflow_run.id }}
54-
continue-on-error: true
65+
script: |
66+
const workflowRun = context.payload.workflow_run;
5567
56-
- name: Read canary info
57-
if: ${{ steps.pr-info.outputs.found == 'true' && github.event.workflow_run.conclusion == 'success' }}
58-
id: canary-info
59-
run: |
60-
if [ -f "canary-info/canary-tags.txt" ]; then
61-
# Read the first tag (DockerHub) from the tags
62-
FIRST_TAG=$(head -n1 canary-info/canary-tags.txt)
63-
echo "tag=$FIRST_TAG" >> $GITHUB_OUTPUT
64-
echo "found=true" >> $GITHUB_OUTPUT
65-
echo "commit-sha=$(cat canary-info/commit-sha.txt)" >> $GITHUB_OUTPUT
66-
else
67-
echo "found=false" >> $GITHUB_OUTPUT
68-
fi
69-
continue-on-error: true
68+
// Extract PR number from the branch name or workflow run
69+
const prNumber = '${{ steps.pr-info.outputs.pr_number }}';
70+
const commitSha = workflowRun.head_sha;
71+
72+
// Generate the canary tag based on the pattern used in canary-deploy.yml
73+
const canaryTag = `supabase/postgres-meta:canary-pr-${prNumber}-${commitSha}`;
74+
75+
core.setOutput('tag', canaryTag);
76+
core.setOutput('found', 'true');
77+
core.setOutput('commit-sha', commitSha);
78+
79+
console.log(`Generated canary tag: ${canaryTag}`);
7080
7181
# Find existing comment
7282
- name: Find existing comment
73-
if: ${{ steps.pr-info.outputs.found == 'true' }}
83+
if: ${{ steps.pr-info.outputs.found == 'true' && steps.pr-info.outputs.has_canary_label == 'true' }}
7484
uses: peter-evans/find-comment@v3
7585
id: find-comment
7686
with:
@@ -80,7 +90,7 @@ jobs:
8090

8191
# Create or update comment based on workflow status
8292
- name: Create or update canary comment
83-
if: ${{ steps.pr-info.outputs.found == 'true' }}
93+
if: ${{ steps.pr-info.outputs.found == 'true' && steps.pr-info.outputs.has_canary_label == 'true' }}
8494
uses: peter-evans/create-or-update-comment@v4
8595
with:
8696
comment-id: ${{ steps.find-comment.outputs.comment-id }}

.github/workflows/canary-deploy.yml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,3 @@ jobs:
105105
org.opencontainers.image.revision=${{ github.event.pull_request.head.sha }}
106106
canary.pr.number=${{ github.event.pull_request.number }}
107107
canary.pr.author=${{ github.event.pull_request.user.login }}
108-
109-
# Save canary info for the comment workflow
110-
- name: Save canary info
111-
run: |
112-
mkdir -p canary-info
113-
echo "${{ steps.meta.outputs.tags }}" > canary-info/canary-tags.txt
114-
echo "${{ github.event.pull_request.number }}" > canary-info/pr-number.txt
115-
echo "${{ github.event.pull_request.head.sha }}" > canary-info/commit-sha.txt
116-
echo "postgres-meta" > canary-info/package-name.txt
117-
118-
- name: Upload canary info
119-
uses: actions/upload-artifact@v4
120-
with:
121-
name: canary-info
122-
path: canary-info/
123-
retention-days: 7

0 commit comments

Comments
 (0)