|
6 | 6 | - 'changeset-release/**'
|
7 | 7 |
|
8 | 8 | jobs:
|
| 9 | + prev-commit: |
| 10 | + name: Verify previous commit |
| 11 | + runs-on: ubuntu-latest |
| 12 | + outputs: |
| 13 | + valid: ${{ steps.prev-commit.outputs.valid }} |
| 14 | + steps: |
| 15 | + - name: Checkout |
| 16 | + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 |
| 17 | + |
| 18 | + # We do not want an infinite loop; therefore, we are checking if the previous |
| 19 | + # commit was created by this action. |
| 20 | + - name: Get previous commit message |
| 21 | + id: prev-commit |
| 22 | + run: | |
| 23 | + echo "valid=$(if [[ $(git log -1 --pretty=%B HEAD) != 'chore: update yarn.lock' ]]; then echo 'true'; else echo 'false'; fi)" >> $GITHUB_OUTPUT |
| 24 | +
|
9 | 25 | update-and-commit-files:
|
10 | 26 | name: Update and commit files
|
| 27 | + needs: prev-commit |
| 28 | + if: needs.prev-commit.outputs.valid == 'true' |
11 | 29 | runs-on: ubuntu-latest
|
12 | 30 |
|
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 |
| - |
17 | 31 | steps:
|
| 32 | + - name: Generate token |
| 33 | + id: generate-token |
| 34 | + uses: actions/create-github-app-token@31c86eb3b33c9b601a1f60f98dcbfd1d70f379b4 # v1.10.3 |
| 35 | + with: |
| 36 | + app-id: ${{ vars.JANUS_IDP_GITHUB_APP_ID }} |
| 37 | + private-key: ${{ secrets.JANUS_IDP_GITHUB_APP_PRIVATE_KEY }} |
| 38 | + |
18 | 39 | - name: Checkout
|
19 | 40 | uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
|
20 | 41 | with:
|
21 |
| - # Fetch the last 2 commits instead of just 1. (Fetching just 1 commit would overwrite the whole history) |
22 |
| - fetch-depth: 2 |
| 42 | + token: ${{ steps.generate-token.outputs.token }} |
23 | 43 |
|
24 | 44 | - name: Setup Node.js
|
25 | 45 | uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
|
|
31 | 51 | # We want to commit the yarn.lock changes
|
32 | 52 | run: yarn install --no-immutable
|
33 | 53 |
|
34 |
| - - name: Get last commit message |
35 |
| - id: last-commit |
36 |
| - run: | |
37 |
| - echo "message=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT |
38 |
| - echo "author=$(git log -1 --pretty=\"%an <%ae>\")" >> $GITHUB_OUTPUT |
39 |
| -
|
40 | 54 | - name: Amend previous commit
|
41 | 55 | uses: stefanzweifel/git-auto-commit-action@v5
|
42 | 56 | 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 |
| 57 | + commit_message: 'chore: update yarn.lock' |
| 58 | + file_pattern: yarn.lock |
0 commit comments