Skip to content

Commit 1df55ac

Browse files
Fix script injection in lint and release workflows (#118)
1 parent b0e99d9 commit 1df55ac

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

.github/workflows/lint.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@ jobs:
2222
fi
2323
- name: Commit changes to PR
2424
if: ${{ env.cbf == 'true' }}
25+
env:
26+
PR_BRANCH: ${{ github.event.pull_request.head.ref }}
2527
run: |
2628
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
2729
git config --global user.name "github-actions[bot]"
2830
if ! git diff-index --quiet HEAD --; then
2931
CHANGES_DETECTED=true
3032
git add *.php
3133
git commit -m "PHPCBF: Fix coding standards" --no-verify
32-
git push origin ${{ github.event.pull_request.head.ref }} || CHANGES_DETECTED=false
34+
git push origin "$PR_BRANCH" || CHANGES_DETECTED=false
3335
echo "changes_detected=$CHANGES_DETECTED" >> $GITHUB_ENV
3436
else
3537
echo "changes_detected=false" >> $GITHUB_ENV
@@ -38,9 +40,10 @@ jobs:
3840
if: ${{ env.changes_detected == 'true' }}
3941
env:
4042
GH_TOKEN: ${{ github.token }}
43+
PR_NUMBER: ${{ github.event.pull_request.number }}
4144
run: |
4245
CURRENT_COMMIT=$(git rev-parse --short HEAD)
43-
gh pr comment ${{ github.event.pull_request.number }} -b "Hi from your friendly Pantheon Robot! :robot: I fixed PHPCS issues with \`phpcbf\` on $CURRENT_COMMIT. Please review the changes."
46+
gh pr comment "$PR_NUMBER" -b "Hi from your friendly Pantheon Robot! :robot: I fixed PHPCS issues with \`phpcbf\` on $CURRENT_COMMIT. Please review the changes."
4447
lint:
4548
name: Lint
4649
runs-on: ubuntu-latest

.github/workflows/release.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ jobs:
3232
3333
- name: Check whether this is a release version
3434
id: check
35+
env:
36+
VERSION: ${{ steps.version.outputs.version }}
3537
run: |
36-
VERSION="${{ steps.version.outputs.version }}"
3738
if [[ "$VERSION" == *-dev ]]; then
3839
echo "is_release=false" >> "$GITHUB_OUTPUT"
3940
echo "Version $VERSION ends in -dev — skipping release."
@@ -50,15 +51,17 @@ jobs:
5051
5152
- name: Create Git tag
5253
if: steps.check.outputs.is_release == 'true'
54+
env:
55+
VERSION: ${{ steps.version.outputs.version }}
5356
run: |
54-
VERSION="${{ steps.version.outputs.version }}"
5557
git tag "$VERSION"
5658
git push origin "$VERSION"
5759
5860
- name: Create GitHub Release
5961
if: steps.check.outputs.is_release == 'true'
62+
env:
63+
VERSION: ${{ steps.version.outputs.version }}
6064
run: |
61-
VERSION="${{ steps.version.outputs.version }}"
6265
gh release create "$VERSION" \
6366
--generate-notes \
6467
--title "$VERSION"
@@ -68,8 +71,9 @@ jobs:
6871
- name: Compute next dev version
6972
if: steps.check.outputs.is_release == 'true'
7073
id: next
74+
env:
75+
VERSION: ${{ steps.version.outputs.version }}
7176
run: |
72-
VERSION="${{ steps.version.outputs.version }}"
7377
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
7478
NEXT_PATCH=$(( PATCH + 1 ))
7579
NEXT_VERSION="${MAJOR}.${MINOR}.${NEXT_PATCH}-dev"
@@ -78,15 +82,17 @@ jobs:
7882
7983
- name: Bump version in pantheon.php
8084
if: steps.check.outputs.is_release == 'true'
85+
env:
86+
NEXT: ${{ steps.next.outputs.next_version }}
8187
run: |
82-
NEXT="${{ steps.next.outputs.next_version }}"
8388
sed -i "s/^\( \* Version: \).*/\1${NEXT}/" pantheon.php
8489
sed -i "s/\(define( 'PANTHEON_MU_PLUGIN_VERSION', '\)[^']*\(.*\)/\1${NEXT}\2/" pantheon.php
8590
8691
- name: Verify both version strings were updated
8792
if: steps.check.outputs.is_release == 'true'
93+
env:
94+
NEXT: ${{ steps.next.outputs.next_version }}
8895
run: |
89-
NEXT="${{ steps.next.outputs.next_version }}"
9096
COUNT=$(grep -c "$NEXT" pantheon.php)
9197
if [ "$COUNT" -lt 2 ]; then
9298
echo "ERROR: Expected at least 2 occurrences of $NEXT in pantheon.php, found $COUNT"
@@ -98,8 +104,9 @@ jobs:
98104
99105
- name: Open version bump PR
100106
if: steps.check.outputs.is_release == 'true'
107+
env:
108+
NEXT: ${{ steps.next.outputs.next_version }}
101109
run: |
102-
NEXT="${{ steps.next.outputs.next_version }}"
103110
BRANCH="chore/bump-version-${NEXT}"
104111
git checkout -b "$BRANCH"
105112
git add pantheon.php

0 commit comments

Comments
 (0)