|
39 | 39 | HUSKY: 0 |
40 | 40 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
41 | 41 |
|
| 42 | + - name: Detect changes after versioning |
| 43 | + id: changes |
| 44 | + shell: bash |
| 45 | + run: | |
| 46 | + if git diff --quiet; then |
| 47 | + echo "has_changes=false" >> "$GITHUB_OUTPUT" |
| 48 | + else |
| 49 | + echo "has_changes=true" >> "$GITHUB_OUTPUT" |
| 50 | + git status --porcelain |
| 51 | + fi |
| 52 | +
|
42 | 53 | - name: Commit version & changelog changes into prep branch |
| 54 | + if: steps.changes.outputs.has_changes == 'true' |
43 | 55 | uses: stefanzweifel/git-auto-commit-action@v5 |
44 | 56 | with: |
45 | 57 | commit_message: "chore: version packages (prepare release)" |
|
49 | 61 | create_branch: true |
50 | 62 |
|
51 | 63 | - name: Open or update PR to release branch |
| 64 | + if: steps.changes.outputs.has_changes == 'true' |
52 | 65 | uses: actions/github-script@v7 |
53 | 66 | with: |
54 | 67 | script: | |
|
64 | 77 | const pr = existing.data[0]; |
65 | 78 | await github.rest.pulls.update({ owner, repo, pull_number: pr.number, title, body }); |
66 | 79 | core.info(`Updated PR #${pr.number}: ${pr.html_url}`); |
67 | | - } else { |
68 | | - const pr = await github.rest.pulls.create({ owner, repo, head: headBranch, base, title, body }); |
69 | | - core.info(`Created PR #${pr.data.number}: ${pr.data.html_url}`); |
| 80 | + return; |
| 81 | + } |
| 82 | +
|
| 83 | + try { |
| 84 | + const cmp = await github.rest.repos.compareCommits({ owner, repo, base, head: headBranch }); |
| 85 | + if (!cmp.data.ahead_by) { |
| 86 | + core.info(`No commits ahead in ${headBranch} vs ${base}. Skipping PR creation.`); |
| 87 | + return; |
| 88 | + } |
| 89 | + } catch (e) { |
| 90 | + core.info(`compareCommits failed: ${e.message}`); |
70 | 91 | } |
| 92 | +
|
| 93 | + const pr = await github.rest.pulls.create({ owner, repo, head: headBranch, base, title, body }); |
| 94 | + core.info(`Created PR #${pr.data.number}: ${pr.data.html_url}`); |
0 commit comments