Skip to content

Commit e8c94cd

Browse files
Update vTagBot.yml
1 parent e4500bd commit e8c94cd

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

.github/workflows/vTagBot.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,35 @@ on:
44
release:
55
types: [released, edited]
66

7+
permissions:
8+
contents: write
9+
710
jobs:
811
sync-version:
912
runs-on: ubuntu-latest
1013

11-
permissions:
12-
contents: write
13-
1414
steps:
1515
- name: Checkout repository
1616
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0 # required so we can switch branches
19+
20+
- name: Detect default branch
21+
id: branch
22+
run: |
23+
DEFAULT_BRANCH=$(git remote show origin | sed -n '/HEAD branch/s/.*: //p')
24+
echo "branch=$DEFAULT_BRANCH" >> $GITHUB_OUTPUT
25+
26+
- name: Switch to default branch
27+
run: |
28+
git checkout "${{ steps.branch.outputs.branch }}"
1729
1830
- name: Extract release tag
1931
run: echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
2032

2133
- name: Update package.json version
2234
run: |
23-
TAG="${RELEASE_TAG#v}" # remove leading "v"
35+
TAG="${RELEASE_TAG#v}"
2436
echo "Updating version to $TAG"
2537
jq ".version = \"$TAG\"" package.json > package.tmp.json
2638
mv package.tmp.json package.json
@@ -29,6 +41,8 @@ jobs:
2941
run: |
3042
git config user.name "vTagBot"
3143
git config user.email "actions@github.com"
44+
3245
git add package.json
3346
git commit -m "chore: sync version to $RELEASE_TAG" || echo "No changes to commit"
34-
git push
47+
48+
git push origin "${{ steps.branch.outputs.branch }}"

0 commit comments

Comments
 (0)