Skip to content

Commit 859bd4d

Browse files
committed
ci(canary-release): Add commit check job to skip redundant releases
- Add new `check-commits` job that runs before canary release - Detect new commits since last canary tag using git rev-list - Skip workflow execution when no new commits exist on scheduled runs - Allow PR and manual triggers to bypass commit check and proceed - Output `has_new_commits` flag for downstream job dependency - Prevents unnecessary canary releases and reduces build overhead
1 parent 200e4fe commit 859bd4d

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

.github/workflows/canary-release.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,50 @@ on:
1515
default: false
1616

1717
jobs:
18+
check-commits:
19+
runs-on: ubuntu-latest
20+
outputs:
21+
has_new_commits: ${{ steps.check.outputs.has_new_commits }}
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Check for new commits since last canary
28+
id: check
29+
run: |
30+
# PR and manual triggers always proceed
31+
if [ "${{ github.event_name }}" != "schedule" ]; then
32+
echo "Trigger is '${{ github.event_name }}' — skipping commit check."
33+
echo "has_new_commits=true" >> "$GITHUB_OUTPUT"
34+
exit 0
35+
fi
36+
37+
git fetch --tags origin
38+
39+
# Find the most recent canary tag
40+
LAST_CANARY=$(git tag --list 'v*-canary-*' --sort=-creatordate | head -1)
41+
42+
if [ -z "$LAST_CANARY" ]; then
43+
echo "No previous canary tag found — proceeding."
44+
echo "has_new_commits=true" >> "$GITHUB_OUTPUT"
45+
exit 0
46+
fi
47+
48+
echo "Last canary tag: $LAST_CANARY"
49+
COMMIT_COUNT=$(git rev-list "${LAST_CANARY}..HEAD" --count)
50+
echo "New commits since $LAST_CANARY: $COMMIT_COUNT"
51+
52+
if [ "$COMMIT_COUNT" -eq 0 ]; then
53+
echo "No new commits since last canary — skipping workflow."
54+
echo "has_new_commits=false" >> "$GITHUB_OUTPUT"
55+
else
56+
echo "has_new_commits=true" >> "$GITHUB_OUTPUT"
57+
fi
58+
1859
canary:
60+
needs: check-commits
61+
if: needs.check-commits.outputs.has_new_commits == 'true'
1962
runs-on: ubuntu-latest
2063
timeout-minutes: 60
2164
permissions:

0 commit comments

Comments
 (0)