9
9
update-and-commit-files :
10
10
name : Update and commit files
11
11
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
+
12
17
steps :
13
18
- name : Checkout
14
19
uses : actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
15
20
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
25
23
26
24
- name : Setup Node.js
27
25
uses : actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
@@ -33,14 +31,17 @@ jobs:
33
31
# We want to commit the yarn.lock changes
34
32
run : yarn install --no-immutable
35
33
36
- - name : Commit changes
37
- env :
38
- GITHUB_TOKEN : ${{ steps.generate-token.outputs.token }}
34
+ - name : Get last commit message
35
+ id : last-commit
39
36
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