|
26 | 26 | with: |
27 | 27 | repository: ${{ github.event.pull_request.head.repo.full_name }} |
28 | 28 | ref: ${{ github.event.pull_request.head.ref }} |
| 29 | + persist-credentials: false |
29 | 30 |
|
30 | 31 | - name: Install Go |
31 | 32 | uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 |
|
43 | 44 | - name: Generate docs |
44 | 45 | run: gomarkdoc --repository.url https://github.com/sumup/sumup-go --repository.default-branch main --output DOCUMENTATION.md ./... |
45 | 46 |
|
46 | | - - name: Commit changes |
47 | | - uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4 |
| 47 | + - name: Create GitHub App token |
| 48 | + id: app-token |
| 49 | + uses: actions/create-github-app-token@67018539274d69449ef7c02e8e71183d1719ab42 # v2.1.4 |
48 | 50 | with: |
49 | | - add: . |
50 | | - message: "chore: generate code" |
51 | | - default_author: github_actions |
| 51 | + app-id: ${{ secrets.SUMUP_BOT_APP_ID }} |
| 52 | + private-key: ${{ secrets.SUMUP_BOT_PRIVATE_KEY }} |
| 53 | + |
| 54 | + - name: Get GitHub App User ID |
| 55 | + id: get-user-id |
| 56 | + run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT" |
| 57 | + env: |
| 58 | + GH_TOKEN: ${{ steps.app-token.outputs.token }} |
| 59 | + |
| 60 | + - name: Configure git |
| 61 | + run: | |
| 62 | + git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]' |
| 63 | + git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com' |
| 64 | +
|
| 65 | + - name: Commit changes |
| 66 | + id: commit |
| 67 | + run: | |
| 68 | + git add . |
| 69 | + if git diff --cached --quiet; then |
| 70 | + echo "changed=false" >> "$GITHUB_OUTPUT" |
| 71 | + else |
| 72 | + git commit -m "chore: generate code" |
| 73 | + echo "changed=true" >> "$GITHUB_OUTPUT" |
| 74 | + fi |
| 75 | +
|
| 76 | + - name: Push changes |
| 77 | + if: steps.commit.outputs.changed == 'true' |
| 78 | + env: |
| 79 | + GH_TOKEN: ${{ steps.app-token.outputs.token }} |
| 80 | + TARGET_REPO: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name || github.repository }} |
| 81 | + TARGET_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref_name }} |
| 82 | + run: | |
| 83 | + git push "https://x-access-token:${GH_TOKEN}@github.com/${TARGET_REPO}.git" HEAD:${TARGET_REF} |
0 commit comments