Skip to content

Commit b539236

Browse files
committed
fix(ci): push RELEASES.md from default branch instead of detached HEAD
1 parent 48dbe9a commit b539236

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

.github/workflows/releases.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@ on:
66
types: [published] # Trigger on new release
77
workflow_dispatch: # Manual trigger
88

9+
permissions:
10+
contents: write
11+
912
jobs:
1013
update-releases-md:
1114
runs-on: ubuntu-latest
1215

1316
steps:
1417
- name: Checkout repo
1518
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
1621

1722
- name: Set up Node.js
1823
uses: actions/setup-node@v4
@@ -26,9 +31,20 @@ jobs:
2631
run: npm run releases
2732

2833
- name: Commit and push .github/RELEASES.md
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2936
run: |
3037
git config user.name "github-actions[bot]"
3138
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
39+
40+
# Switch to the default branch
41+
git fetch origin
42+
DEFAULT_BRANCH=$(git remote show origin | sed -n '/HEAD branch/s/.*: //p')
43+
git checkout $DEFAULT_BRANCH
44+
git pull origin $DEFAULT_BRANCH
45+
3246
git add .github/RELEASES.md
3347
git commit -m "docs: update RELEASES.md on new release" || echo "No changes"
34-
git push
48+
49+
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}
50+
git push origin $DEFAULT_BRANCH

0 commit comments

Comments
 (0)