Skip to content

Commit

Permalink
chore(gh): switch gh action commit step to an action (janus-idp#2414)
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Schultz <pschultz@pobox.com>
  • Loading branch information
schultzp2020 authored and 04kash committed Oct 23, 2024
1 parent ad0f4ad commit e5f8bc9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
2 changes: 2 additions & 0 deletions .changeset/chilled-toys-double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
39 changes: 20 additions & 19 deletions .github/workflows/update-changeset-prs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,17 @@ jobs:
update-and-commit-files:
name: Update and commit files
runs-on: ubuntu-latest

permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the changed files back to the repository.
contents: write

steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
# don't persist the GITHUB_TOKEN so the release can use use the generated token
persist-credentials: false

- name: Generate token
id: generate-token
uses: actions/create-github-app-token@31c86eb3b33c9b601a1f60f98dcbfd1d70f379b4 # v1.10.3
with:
app-id: ${{ vars.JANUS_IDP_GITHUB_APP_ID }}
private-key: ${{ secrets.JANUS_IDP_GITHUB_APP_PRIVATE_KEY }}
# Fetch the last 2 commits instead of just 1. (Fetching just 1 commit would overwrite the whole history)
fetch-depth: 2

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

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

0 comments on commit e5f8bc9

Please sign in to comment.