|
4 | 4 | pull_request: |
5 | 5 | types: [closed] |
6 | 6 | branches: [main] |
7 | | - push: |
8 | | - branches: [main] |
9 | | - paths-ignore: |
10 | | - - 'package.json' |
11 | | - - 'package-lock.json' |
12 | | - - 'CHANGELOG.md' |
13 | 7 |
|
14 | 8 | jobs: |
15 | 9 | version-and-release: |
16 | | - # Only run on merged PRs or direct pushes (not on close without merge) |
17 | | - if: | |
18 | | - (github.event_name == 'pull_request' && github.event.pull_request.merged == true) || |
19 | | - (github.event_name == 'push' && !contains(github.event.head_commit.message, '[skip ci]')) |
| 10 | + # Only run on merged PRs to main (not on close without merge or direct pushes to feature branches) |
| 11 | + if: github.event.pull_request.merged == true |
20 | 12 |
|
21 | 13 | runs-on: ubuntu-latest |
22 | 14 | permissions: |
@@ -65,43 +57,15 @@ jobs: |
65 | 57 | exit 0 |
66 | 58 | fi |
67 | 59 | |
68 | | - # For PRs, get the source branch name |
69 | | - if [ "${{ github.event_name }}" == "pull_request" ]; then |
70 | | - BRANCH_NAME="${{ github.event.pull_request.head.ref }}" |
71 | | - echo "Source branch: $BRANCH_NAME" |
72 | | -
|
73 | | - # Check if this is a Dependabot PR |
74 | | - if [ "${{ github.event.pull_request.user.login }}" == "dependabot[bot]" ] || echo "$BRANCH_NAME" | grep -qE '^dependabot/'; then |
75 | | - echo "🤖 Dependabot PR detected - no version bump" |
76 | | - echo "skip=true" >> $GITHUB_OUTPUT |
77 | | - exit 0 |
78 | | - fi |
79 | | - else |
80 | | - # For direct pushes, check commit message for branch info |
81 | | - BRANCH_NAME=$(git log -1 --pretty=%B | grep -oP '(?<=from )[^\s]+' || echo "") |
82 | | - if [ -z "$BRANCH_NAME" ]; then |
83 | | - echo "No branch info in commit, checking for version tags in message" |
84 | | - COMMIT_MSG=$(git log -1 --pretty=%B) |
85 | | -
|
86 | | - # Check for Dependabot commits |
87 | | - if echo "$COMMIT_MSG" | grep -qE 'Bump .* from .* to .*|^\[dependabot\]|^chore\(deps'; then |
88 | | - echo "🤖 Dependabot commit detected - no version bump" |
89 | | - echo "skip=true" >> $GITHUB_OUTPUT |
90 | | - exit 0 |
91 | | - fi |
92 | | -
|
93 | | - if echo "$COMMIT_MSG" | grep -qiE '\[major\]|breaking'; then |
94 | | - BRANCH_NAME="major/direct" |
95 | | - elif echo "$COMMIT_MSG" | grep -qiE '\[minor\]|feat'; then |
96 | | - BRANCH_NAME="feature/direct" |
97 | | - elif echo "$COMMIT_MSG" | grep -qiE '\[patch\]|fix'; then |
98 | | - BRANCH_NAME="fix/direct" |
99 | | - else |
100 | | - echo "No version bump needed" |
101 | | - echo "skip=true" >> $GITHUB_OUTPUT |
102 | | - exit 0 |
103 | | - fi |
104 | | - fi |
| 60 | + # Get the source branch name from the PR |
| 61 | + BRANCH_NAME="${{ github.event.pull_request.head.ref }}" |
| 62 | + echo "Source branch: $BRANCH_NAME" |
| 63 | +
|
| 64 | + # Check if this is a Dependabot PR |
| 65 | + if [ "${{ github.event.pull_request.user.login }}" == "dependabot[bot]" ] || echo "$BRANCH_NAME" | grep -qE '^dependabot/'; then |
| 66 | + echo "🤖 Dependabot PR detected - no version bump" |
| 67 | + echo "skip=true" >> $GITHUB_OUTPUT |
| 68 | + exit 0 |
105 | 69 | fi |
106 | 70 |
|
107 | 71 | # Determine version bump type based on branch prefix |
|
0 commit comments