Skip to content

Commit 5402503

Browse files
committed
Use environment variables in workflow for automated version increments
to harden workflow against poisoned pipeline executions (PPE).
1 parent 654ef59 commit 5402503

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

.github/workflows/publishVersionCheckResults.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ jobs:
6464
- name: Apply and push version increment
6565
id: git-commit
6666
if: steps.search-patch.outputs.result
67+
env:
68+
REPOSITORY_NAME: ${{ github.event.workflow_run.head_repository.full_name }}
69+
BRANCH_NAME: ${{ github.event.workflow_run.head_branch }}
70+
BOT_PA_TOKEN: ${{ secrets.githubBotPAT }}
6771
run: |
6872
set -x
6973
# Set initial placeholder name/mail and read it from the patch later
@@ -85,10 +89,8 @@ jobs:
8589
echo "EOF" >> $GITHUB_OUTPUT
8690
8791
git push \
88-
"https://oauth2:${BOT_PA_TOKEN}@github.com/${{ github.event.workflow_run.head_repository.full_name }}.git" \
89-
'HEAD:refs/heads/${{ github.event.workflow_run.head_branch }}'
90-
env:
91-
BOT_PA_TOKEN: ${{ secrets.githubBotPAT }}
92+
"https://oauth2:${BOT_PA_TOKEN}@github.com/${REPOSITORY_NAME}.git" \
93+
"HEAD:refs/heads/${BRANCH_NAME}"
9294
9395
- name: Find existing information comment
9496
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0
@@ -103,11 +105,13 @@ jobs:
103105
- name: Add or update information comment
104106
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
105107
if: always()
108+
env:
109+
FILELIST: ${{ steps.git-commit.outputs.file-list }}
106110
with:
107111
github-token: ${{ secrets.githubBotPAT }}
108112
script: |
109113
const fs = require('fs')
110-
const fileList = `${{ steps.git-commit.outputs.file-list }}`
114+
const fileList = process.env.FILELIST
111115
if (fileList) { // if list is empty, no versions were changed
112116
const commentBody = `
113117
${{ env.COMMENT_FIRST_LINE }}.

0 commit comments

Comments
 (0)