Skip to content

Commit c231675

Browse files
committed
Add early exit logic when no new commits to release
- Add commit check step following build.yml pattern - Skip PR creation when no new commits between rel/weekly and main - Satisfy linter by declaring HAS_NEW_COMMITS environment variable - Prevents workflow failure when branches are synchronized
1 parent ac8a3cc commit c231675

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

.github/workflows/scheduled-releases.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
env:
1616
# Declare to satisfy linter, will be set dynamically during workflow execution
1717
PR_NUMBER: ""
18+
HAS_NEW_COMMITS: ""
1819

1920
steps:
2021
- name: Checkout repository
@@ -27,7 +28,15 @@ jobs:
2728
git config user.name 'github-actions[bot]'
2829
git config user.email 'github-actions[bot]@users.noreply.github.com'
2930
31+
- name: Check for new commits
32+
shell: pwsh
33+
run: |
34+
# Check if there are commits between rel/weekly and main
35+
$commitCount = git rev-list --count rel/weekly..main
36+
echo "HAS_NEW_COMMITS=$($commitCount -gt 0)" >> $env:GITHUB_ENV
37+
3038
- name: Create weekly release PR
39+
if: ${{ env.HAS_NEW_COMMITS == 'true' }}
3140
shell: pwsh
3241
run: |
3342
# Create PR from main to rel/weekly, capture created URL
@@ -45,6 +54,7 @@ jobs:
4554
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4655

4756
- name: Enable auto-merge for the PR
57+
if: ${{ env.HAS_NEW_COMMITS == 'true' }}
4858
shell: pwsh
4959
run: |
5060
gh pr merge ${{ env.PR_NUMBER }} --auto --rebase

0 commit comments

Comments
 (0)