Skip to content

Commit 17f2d9b

Browse files
authored
chore(gh): switch gh action commit step to an action (#2414)
Signed-off-by: Paul Schultz <[email protected]>
1 parent 4b88850 commit 17f2d9b

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

.changeset/chilled-toys-double.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

.github/workflows/update-changeset-prs.yaml

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,17 @@ jobs:
99
update-and-commit-files:
1010
name: Update and commit files
1111
runs-on: ubuntu-latest
12+
13+
permissions:
14+
# Give the default GITHUB_TOKEN write permission to commit and push the changed files back to the repository.
15+
contents: write
16+
1217
steps:
1318
- name: Checkout
1419
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
1520
with:
16-
# don't persist the GITHUB_TOKEN so the release can use use the generated token
17-
persist-credentials: false
18-
19-
- name: Generate token
20-
id: generate-token
21-
uses: actions/create-github-app-token@31c86eb3b33c9b601a1f60f98dcbfd1d70f379b4 # v1.10.3
22-
with:
23-
app-id: ${{ vars.JANUS_IDP_GITHUB_APP_ID }}
24-
private-key: ${{ secrets.JANUS_IDP_GITHUB_APP_PRIVATE_KEY }}
21+
# Fetch the last 2 commits instead of just 1. (Fetching just 1 commit would overwrite the whole history)
22+
fetch-depth: 2
2523

2624
- name: Setup Node.js
2725
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
@@ -33,14 +31,17 @@ jobs:
3331
# We want to commit the yarn.lock changes
3432
run: yarn install --no-immutable
3533

36-
- name: Commit changes
37-
env:
38-
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
34+
- name: Get last commit message
35+
id: last-commit
3936
run: |
40-
git config user.name 'janus-idp[bot]'
41-
git config user.email '41898282+janus-idp[bot]@users.noreply.github.com'
42-
git add yarn.lock
43-
if [[ -n $(git status --porcelain) ]]; then
44-
git commit -m 'chore: update yarn.lock'
45-
git push origin HEAD:${{ github.ref }}
46-
fi
37+
echo "message=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT
38+
echo "author=$(git log -1 --pretty=\"%an <%ae>\")" >> $GITHUB_OUTPUT
39+
40+
- name: Amend previous commit
41+
uses: stefanzweifel/git-auto-commit-action@v5
42+
with:
43+
commit_author: ${{ steps.last-commit.outputs.author }}
44+
commit_message: ${{ steps.last-commit.outputs.message }}
45+
commit_options: '--amend --no-edit'
46+
push_options: '--force'
47+
skip_fetch: true

0 commit comments

Comments
 (0)