77
77
- uses : actions/checkout@v4
78
78
with :
79
79
ref : ${{ needs.compute-sha.outputs.SHA }}
80
+ fetch-depth : 0
80
81
persist-credentials : false
81
82
82
83
- name : Get artifacts
93
94
94
95
- name : Update screenshots
95
96
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
+
96
108
# Install prerequisites.
97
109
npm ci
98
110
@@ -104,7 +116,8 @@ jobs:
104
116
git config user.name "shaka-bot"
105
117
git config user.email "[email protected] "
106
118
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.
108
121
git add test/test/assets/screenshots/*/*.png || true
109
122
git commit -m ':robot: Update all screenshots' || true
110
123
@@ -113,6 +126,8 @@ jobs:
113
126
GH_TOKEN : ${{ github.token }}
114
127
run : |
115
128
# Update the PR.
129
+
130
+ # Compute the destination for the push.
116
131
PR_API_URL="/repos/${{ github.repository }}/pulls/${{ inputs.pr }}"
117
132
REMOTE=$(gh api $PR_API_URL | jq -r .head.repo.html_url)
118
133
BRANCH=$(gh api $PR_API_URL | jq -r .head.ref)
0 commit comments