2929 runs-on : ubuntu-latest
3030 container :
3131 image : archlinux:base-devel@sha256:767de6eaa40dcfeda5263a48737ea03a782caabdf3a403b6e6a203c7fd333681
32+ outputs :
33+ created : ${{ steps.stage_updated_metadata.outputs.created }}
3234 permissions :
3335 contents : read
3436 steps :
@@ -83,27 +85,80 @@ jobs:
8385 )
8486 done
8587
86- - name : Commit updated metadata
87- id : commit_updated_metadata
88+ - name : Stage updated metadata
89+ id : stage_updated_metadata
8890 shell : bash
8991 run : |
9092 set -euo pipefail
9193
9294 echo 'created=false' >> "$GITHUB_OUTPUT"
93- git config user.name 'renovate[bot]'
94- git config user.email '29139614+renovate[bot]@users.noreply.github.com'
9595 git add -- '*/PKGBUILD' '*/.SRCINFO'
9696 if git diff --cached --quiet; then
9797 echo 'Package metadata is already current.'
9898 exit 0
9999 fi
100- git commit -m 'chore: update package metadata'
100+
101+ while IFS= read -r path; do
102+ if [[ ! $path =~ ^[a-z0-9][a-z0-9@._+-]*/(PKGBUILD|\.SRCINFO)$ ]]; then
103+ echo "Refusing to export unexpected changed path: $path" >&2
104+ exit 1
105+ fi
106+ done < <(git diff --cached --name-only)
107+
108+ git diff --cached --binary > "$RUNNER_TEMP/metadata.patch"
101109 echo 'created=true' >> "$GITHUB_OUTPUT"
102110
111+ - name : Upload updated metadata
112+ if : steps.stage_updated_metadata.outputs.created == 'true'
113+ uses : actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
114+ with :
115+ name : package-metadata-${{ github.run_id }}
116+ path : ${{ runner.temp }}/metadata.patch
117+ if-no-files-found : error
118+ retention-days : 1
119+
120+ push :
121+ name : Commit updated metadata
122+ needs : update
123+ if : needs.update.outputs.created == 'true'
124+ runs-on : ubuntu-latest
125+ container :
126+ image : archlinux:base-devel@sha256:767de6eaa40dcfeda5263a48737ea03a782caabdf3a403b6e6a203c7fd333681
127+ permissions :
128+ contents : read
129+ steps :
130+ - name : Install tools
131+ run : pacman -Syu --noconfirm --needed git github-cli
132+
133+ - name : Check out Renovate branch
134+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
135+ with :
136+ fetch-depth : 0
137+ ref : ${{ github.event.pull_request.head.sha }}
138+ persist-credentials : false
139+
140+ - name : Download updated metadata
141+ uses : actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
142+ with :
143+ name : package-metadata-${{ github.run_id }}
144+ path : ${{ runner.temp }}/metadata
145+
146+ - name : Apply updated metadata
147+ shell : bash
148+ run : |
149+ set -euo pipefail
150+
151+ git apply --index "$RUNNER_TEMP/metadata/metadata.patch"
152+ while IFS= read -r path; do
153+ if [[ ! $path =~ ^[a-z0-9][a-z0-9@._+-]*/(PKGBUILD|\.SRCINFO)$ ]]; then
154+ echo "Refusing to commit unexpected changed path: $path" >&2
155+ exit 1
156+ fi
157+ done < <(git diff --cached --name-only)
158+
103159 # GITHUB_TOKEN commits do not trigger another workflow run, so the
104- # narrowly scoped PAT is used only for this final push.
105- - name : Push updated metadata
106- if : steps.commit_updated_metadata.outputs.created == 'true'
160+ # narrowly scoped PAT is used only in this isolated push job.
161+ - name : Commit and push updated metadata
107162 env :
108163 GITHUB_TOKEN : ${{ github.token }}
109164 METADATA_PUSH_TOKEN : ${{ secrets.METADATA_PUSH_TOKEN }}
@@ -113,6 +168,9 @@ jobs:
113168 run : |
114169 set -euo pipefail
115170
171+ git config user.name 'renovate[bot]'
172+ git config user.email '29139614+renovate[bot]@users.noreply.github.com'
173+
116174 current_head_sha=$(gh api \
117175 "repos/${GITHUB_REPOSITORY}/git/ref/heads/${GITHUB_HEAD_REF}" \
118176 --jq .object.sha)
0 commit comments