Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 37 additions & 27 deletions .github/workflows/canary-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,42 +35,52 @@ jobs:

if (prs.data.length > 0) {
const pr = prs.data[0];
core.setOutput('pr_number', pr.number);
core.setOutput('found', 'true');
console.log(`Found PR #${pr.number}`);

// Check if PR has the deploy-canary label
const labels = pr.labels.map(label => label.name);
const hasCanaryLabel = labels.includes('deploy-canary');

if (hasCanaryLabel) {
core.setOutput('pr_number', pr.number);
core.setOutput('found', 'true');
core.setOutput('has_canary_label', 'true');
console.log(`Found PR #${pr.number} with deploy-canary label`);
} else {
core.setOutput('found', 'false');
core.setOutput('has_canary_label', 'false');
console.log(`Found PR #${pr.number} but it doesn't have deploy-canary label`);
}
} else {
core.setOutput('found', 'false');
core.setOutput('has_canary_label', 'false');
console.log('No associated PR found');
}

# Only continue if we found a PR and the workflow succeeded
- name: Download canary info
if: ${{ steps.pr-info.outputs.found == 'true' && github.event.workflow_run.conclusion == 'success' }}
uses: actions/download-artifact@v4
# Extract canary info from the workflow run
- name: Extract canary info
if: ${{ steps.pr-info.outputs.found == 'true' && steps.pr-info.outputs.has_canary_label == 'true' && github.event.workflow_run.conclusion == 'success' }}
id: canary-info
uses: actions/github-script@v7
with:
name: canary-info
path: canary-info/
run-id: ${{ github.event.workflow_run.id }}
continue-on-error: true
script: |
const workflowRun = context.payload.workflow_run;

- name: Read canary info
if: ${{ steps.pr-info.outputs.found == 'true' && github.event.workflow_run.conclusion == 'success' }}
id: canary-info
run: |
if [ -f "canary-info/canary-tags.txt" ]; then
# Read the first tag (DockerHub) from the tags
FIRST_TAG=$(head -n1 canary-info/canary-tags.txt)
echo "tag=$FIRST_TAG" >> $GITHUB_OUTPUT
echo "found=true" >> $GITHUB_OUTPUT
echo "commit-sha=$(cat canary-info/commit-sha.txt)" >> $GITHUB_OUTPUT
else
echo "found=false" >> $GITHUB_OUTPUT
fi
continue-on-error: true
// Extract PR number from the branch name or workflow run
const prNumber = '${{ steps.pr-info.outputs.pr_number }}';
const commitSha = workflowRun.head_sha;

// Generate the canary tag based on the pattern used in canary-deploy.yml
const canaryTag = `supabase/postgres-meta:canary-pr-${prNumber}-${commitSha}`;

core.setOutput('tag', canaryTag);
core.setOutput('found', 'true');
core.setOutput('commit-sha', commitSha);

console.log(`Generated canary tag: ${canaryTag}`);

# Find existing comment
- name: Find existing comment
if: ${{ steps.pr-info.outputs.found == 'true' }}
if: ${{ steps.pr-info.outputs.found == 'true' && steps.pr-info.outputs.has_canary_label == 'true' }}
uses: peter-evans/find-comment@v3
id: find-comment
with:
Expand All @@ -80,7 +90,7 @@ jobs:

# Create or update comment based on workflow status
- name: Create or update canary comment
if: ${{ steps.pr-info.outputs.found == 'true' }}
if: ${{ steps.pr-info.outputs.found == 'true' && steps.pr-info.outputs.has_canary_label == 'true' }}
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
Expand Down
16 changes: 0 additions & 16 deletions .github/workflows/canary-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,3 @@ jobs:
org.opencontainers.image.revision=${{ github.event.pull_request.head.sha }}
canary.pr.number=${{ github.event.pull_request.number }}
canary.pr.author=${{ github.event.pull_request.user.login }}

# Save canary info for the comment workflow
- name: Save canary info
run: |
mkdir -p canary-info
echo "${{ steps.meta.outputs.tags }}" > canary-info/canary-tags.txt
echo "${{ github.event.pull_request.number }}" > canary-info/pr-number.txt
echo "${{ github.event.pull_request.head.sha }}" > canary-info/commit-sha.txt
echo "postgres-meta" > canary-info/package-name.txt

- name: Upload canary info
uses: actions/upload-artifact@v4
with:
name: canary-info
path: canary-info/
retention-days: 7