@@ -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 :
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 }}
0 commit comments