Skip to content

Commit 8ff80cc

Browse files
authored
Merge pull request #27 from IShix-g/release
fix: handle ref determination for pull request events
2 parents ee4de8c + 5614308 commit 8ff80cc

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

.github/workflows/toc-generator_push.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,15 @@ jobs:
1515
steps:
1616
- name: Check if ref is not default branch
1717
run: |
18-
target_branch="${{ github.ref }}"
18+
if [ "${{ github.event_name }}" == "pull_request" ]; then
19+
target_branch="${{ github.event.pull_request.base.ref }}"
20+
else
21+
target_branch=$(echo "${{ github.ref }}" | sed 's|refs/heads/||')
22+
fi
23+
1924
default_branch="${{ github.event.repository.default_branch }}"
2025
21-
if [[ "$target_branch" != "refs/heads/$default_branch" ]]; then
26+
if [[ "$target_branch" != "$default_branch" ]]; then
2227
echo "::notice::This is not the default branch. ($default_branch)"
2328
echo "Target branch: $target_branch"
2429
echo "Default branch: $default_branch"

0 commit comments

Comments
 (0)