|
21 | 21 | id: generate-commits |
22 | 22 | run: | |
23 | 23 | chmod +x .github/scripts/promote_to_master.sh |
24 | | - .github/scripts/promote_to_master.sh |
| 24 | + bash .github/scripts/promote_to_master.sh |
25 | 25 |
|
26 | 26 | # Use a fixed branch name for the PR |
27 | 27 | - name: Update dev-to-master branch |
|
37 | 37 | git checkout -b $BRANCH_NAME |
38 | 38 | git push --force origin $BRANCH_NAME |
39 | 39 |
|
| 40 | + # Check if there are any commits between master and our branch |
| 41 | + - name: Check for commits between branches |
| 42 | + id: check-commits |
| 43 | + run: | |
| 44 | + # Compare the branches to see if there are any differences |
| 45 | + COMMIT_COUNT=$(git rev-list --count master..$BRANCH_NAME) |
| 46 | + echo "commit_count=$COMMIT_COUNT" >> $GITHUB_OUTPUT |
| 47 | + if [ "$COMMIT_COUNT" -gt 0 ]; then |
| 48 | + echo "Detected $COMMIT_COUNT commit(s) between master and $BRANCH_NAME" |
| 49 | + echo "has_commits=true" >> $GITHUB_OUTPUT |
| 50 | + else |
| 51 | + echo "No commits detected between master and $BRANCH_NAME" |
| 52 | + echo "has_commits=false" >> $GITHUB_OUTPUT |
| 53 | + fi |
| 54 | + env: |
| 55 | + BRANCH_NAME: "automated-dev-to-master-branch" |
| 56 | + |
40 | 57 | # Create or update PR using GitHub API with retry logic |
41 | 58 | - name: Create or Update Pull Request |
| 59 | + if: steps.check-commits.outputs.has_commits == 'true' |
42 | 60 | uses: actions/github-script@v6 |
43 | 61 | with: |
44 | 62 | github-token: ${{ secrets.GITHUB_TOKEN }} |
@@ -113,6 +131,13 @@ jobs: |
113 | 131 | } |
114 | 132 | } |
115 | 133 |
|
| 134 | + # Output message when no commits are found |
| 135 | + - name: No Commits Message |
| 136 | + if: steps.check-commits.outputs.has_commits == 'false' |
| 137 | + run: | |
| 138 | + echo "::notice::No new commits detected between master and dev branches. Skipping PR creation." |
| 139 | + echo "The branches master and dev are already in sync." |
| 140 | +
|
116 | 141 | release: |
117 | 142 | name: release |
118 | 143 | if: ${{ github.ref == 'refs/heads/master' }} |
|
0 commit comments