Skip to content

Commit 98a8d79

Browse files
committed
wip: safeguards
1 parent 872d5fb commit 98a8d79

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

.github/workflows/update-screenshots.yaml

+16-1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ jobs:
7777
- uses: actions/checkout@v4
7878
with:
7979
ref: ${{ needs.compute-sha.outputs.SHA }}
80+
fetch-depth: 0
8081
persist-credentials: false
8182

8283
- name: Get artifacts
@@ -93,6 +94,17 @@ jobs:
9394

9495
- name: Update screenshots
9596
run: |
97+
# NPM packages and the image update scripts could all be modified by
98+
# an attacker to inject code into this step of the workflow. Use
99+
# copies of those files from the main branch as a safeguard. Up to
100+
# now, nothing controlled by the PR author has been executed.
101+
git restore --source origin/main -- \
102+
package-lock.json \
103+
package.json \
104+
build/shakaBuildHelpers.py \
105+
build/updateScreenshots.py \
106+
build/imageSimilarity.js
107+
96108
# Install prerequisites.
97109
npm ci
98110
@@ -104,7 +116,8 @@ jobs:
104116
git config user.name "shaka-bot"
105117
git config user.email "[email protected]"
106118
107-
# Commit the changes. Ignore failure, in case there are no changes.
119+
# Commit the changes to the screenshots only. Ignore failure, in
120+
# case there are no changes.
108121
git add test/test/assets/screenshots/*/*.png || true
109122
git commit -m ':robot: Update all screenshots' || true
110123
@@ -113,6 +126,8 @@ jobs:
113126
GH_TOKEN: ${{ github.token }}
114127
run: |
115128
# Update the PR.
129+
130+
# Compute the destination for the push.
116131
PR_API_URL="/repos/${{ github.repository }}/pulls/${{ inputs.pr }}"
117132
REMOTE=$(gh api $PR_API_URL | jq -r .head.repo.html_url)
118133
BRANCH=$(gh api $PR_API_URL | jq -r .head.ref)

0 commit comments

Comments
 (0)