@@ -35,42 +35,52 @@ jobs:
35
35
36
36
if (prs.data.length > 0) {
37
37
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
+ }
41
53
} else {
42
54
core.setOutput('found', 'false');
55
+ core.setOutput('has_canary_label', 'false');
43
56
console.log('No associated PR found');
44
57
}
45
58
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
50
64
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;
55
67
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}`);
70
80
71
81
# Find existing comment
72
82
- 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' }}
74
84
uses : peter-evans/find-comment@v3
75
85
id : find-comment
76
86
with :
80
90
81
91
# Create or update comment based on workflow status
82
92
- 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' }}
84
94
uses : peter-evans/create-or-update-comment@v4
85
95
with :
86
96
comment-id : ${{ steps.find-comment.outputs.comment-id }}
0 commit comments