|
55 | 55 | repository: ${{ github.event.pull_request.head.repo.full_name }} |
56 | 56 | ref: ${{ github.event.pull_request.head.ref }} |
57 | 57 | fetch-depth: 0 |
| 58 | + # Credentials are re-introduced only in the final push step. |
| 59 | + persist-credentials: false |
58 | 60 | - name: Configure curl and wget |
59 | 61 | uses: ./.github/actions/setup-curl |
60 | 62 | # |
@@ -134,7 +136,24 @@ jobs: |
134 | 136 | - name: Git pull |
135 | 137 | run: git pull --rebase --autostash . |
136 | 138 | - uses: EndBug/add-and-commit@290ea2c423ad77ca9c62ae0f5b224379612c0321 # v10.0.0 |
| 139 | + id: commit |
137 | 140 | with: |
138 | 141 | author_name: "renovate[bot]" |
139 | 142 | author_email: "29139614+renovate[bot]@users.noreply.github.com" |
140 | 143 | message: "chore(deps): post upgrade tasks - go mod tidy, update golden files, readme, and schema" |
| 144 | + # Pushing is done by the next step; checkout does not persist credentials. |
| 145 | + push: false |
| 146 | + - name: Push changes |
| 147 | + if: steps.commit.outputs.committed == 'true' |
| 148 | + env: |
| 149 | + GH_APP_TOKEN: ${{ steps.generate-github-token.outputs.token }} |
| 150 | + # Mirrors how actions/checkout resolved its own repository/ref inputs. |
| 151 | + TARGET_REPO: ${{ github.event.pull_request.head.repo.full_name || github.repository }} |
| 152 | + TARGET_REF: ${{ github.event.pull_request.head.ref || github.ref_name }} |
| 153 | + run: | |
| 154 | + set -euo pipefail |
| 155 | + # Credential is supplied per-command via a helper reading the step env, so the token is |
| 156 | + # neither written to .git/config nor visible in the process arguments. |
| 157 | + git -c credential.helper= \ |
| 158 | + -c credential.helper='!f() { echo username=x-access-token; echo "password=${GH_APP_TOKEN}"; }; f' \ |
| 159 | + push origin "HEAD:refs/heads/${TARGET_REF}" |
0 commit comments