Repository navigation
Expand file tree
/
Copy pathreleases.yml
More file actions
52 lines (40 loc) · 1.52 KB
/
Copy pathreleases.yml
File metadata and controls
52 lines (40 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# This workflow will update the `.github/RELEASES.md` file whenever a new release is published.
name: Update RELEASES.md
on:
release:
types: [published] # Trigger on new release
workflow_dispatch: # Manual trigger
permissions:
contents: write
jobs:
update-releases-md:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Install dependencies
run: npm install
- name: Generate RELEASES.md
run: npm run releases
- name: Commit and push .github/RELEASES.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# Switch to the default branch
git fetch origin
DEFAULT_BRANCH=$(git remote show origin | sed -n '/HEAD branch/s/.*: //p')
git checkout $DEFAULT_BRANCH
git add .github/RELEASES.md
git commit -m "docs: update RELEASES.md on new release" || echo "No changes"
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}
# Pull latest remote changes with rebase right before pushing
git pull --rebase origin $DEFAULT_BRANCH
git push origin $DEFAULT_BRANCH