4040 if : ${{ github.repository == 'wordpress/wordpress-develop' }}
4141 timeout-minutes : 10
4242 permissions :
43- contents : write
43+ # The actual `git push` is authenticated via a dedicated GitHub App installation token
44+ # generated below, so `GITHUB_TOKEN` only needs read access to the triggering workflow's artifacts.
45+ actions : read # Required to list and download the artifact uploaded by the triggering workflow run.
4446 steps :
4547 - name : Download artifact
4648 uses : actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
@@ -90,21 +92,18 @@ jobs:
9092 id : generate_token
9193 if : ${{ steps.artifact-check.outputs.exists == 'true' }}
9294 env :
93- GH_APP_ID : ${{ secrets .GH_PR_BUILT_FILES_APP_ID }}
95+ GH_APP_ID : ${{ vars .GH_PR_BUILT_FILES_APP_ID }}
9496 GH_APP_PRIVATE_KEY : ${{ secrets.GH_PR_BUILT_FILES_PRIVATE_KEY }}
9597 run : |
96- echo "$GH_APP_PRIVATE_KEY" > private-key.pem
97-
9898 # Generate JWT
9999 JWT=$(python3 - <<EOF
100- import jwt, time
101- private_key = open("private-key.pem", "r").read()
100+ import jwt, time, os
102101 payload = {
103102 "iat": int(time.time()),
104103 "exp": int(time.time()) + 600, # 10-minute expiration
105- "iss": $ GH_APP_ID
104+ "iss": int(os.environ[" GH_APP_ID"]),
106105 }
107- print(jwt.encode(payload, private_key , algorithm="RS256"))
106+ print(jwt.encode(payload, os.environ["GH_APP_PRIVATE_KEY"] , algorithm="RS256"))
108107 EOF
109108 )
110109
@@ -118,9 +117,7 @@ jobs:
118117 -H "Accept: application/vnd.github.v3+json" \
119118 "https://api.github.com/app/installations/$INSTALLATION_ID/access_tokens" | jq -r '.token')
120119
121- echo "ACCESS_TOKEN=$ACCESS_TOKEN" >> "$GITHUB_ENV"
122-
123- rm -f private-key.pem
120+ echo "access-token=$ACCESS_TOKEN" >> "$GITHUB_OUTPUT"
124121
125122 - name : Checkout repository
126123 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -130,7 +127,7 @@ jobs:
130127 ref : ${{ github.event.workflow_run.head_branch }}
131128 path : ' pr-repo'
132129 show-progress : ${{ runner.debug == '1' && 'true' || 'false' }}
133- token : ${{ env.ACCESS_TOKEN }}
130+ token : ${{ steps.generate_token.outputs.access-token }}
134131 persist-credentials : true
135132
136133 - name : Apply patch
@@ -147,7 +144,7 @@ jobs:
147144 if : ${{ steps.artifact-check.outputs.exists == 'true' }}
148145 working-directory : ' pr-repo'
149146 env :
150- GH_APP_ID : ${{ secrets .GH_PR_BUILT_FILES_APP_ID }}
147+ GH_APP_ID : ${{ vars .GH_PR_BUILT_FILES_APP_ID }}
151148 run : |
152149 git config user.name "wordpress-develop-pr-bot[bot]"
153150 git config user.email "${GH_APP_ID}+wordpress-develop-pr-bot[bot]@users.noreply.github.com"
0 commit comments