Skip to content

Commit c4e9410

Browse files
committed
MESH-2530 Address github action vulnerability
1 parent efb0060 commit c4e9410

File tree

1 file changed

+27
-21
lines changed

1 file changed

+27
-21
lines changed

.github/workflows/pull-request.yml

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ permissions:
88
pull-requests: write
99

1010
jobs:
11-
1211
tox:
1312
strategy:
1413
matrix:
@@ -37,11 +36,14 @@ jobs:
3736
- name: merge into base_branch
3837
if: ${{ github.event_name == 'pull_request' }}
3938
run: |
40-
echo base branch "${{ github.base_ref }}"
41-
echo pr branch "${{ github.head_ref }}"
42-
git checkout "${{ github.base_ref }}"
39+
echo base branch "$BASE_BRANCH"
40+
echo pr branch "$PR_BRANCH"
41+
git checkout "$BASE_BRANCH"
4342
git checkout -b "merging-${{ github.event.number }}"
4443
git merge --ff-only "${{ github.event.pull_request.head.sha }}"
44+
env:
45+
BASE_BRANCH: ${{ github.base_ref }}
46+
PR_BRANCH: ${{ github.head_ref }}
4547

4648
- name: setup python
4749
uses: actions/setup-python@v5
@@ -61,7 +63,6 @@ jobs:
6163
if: success() || failure()
6264
run: make down
6365

64-
6566
coverage:
6667
runs-on: ubuntu-latest
6768
if: github.repository == 'NHSDigital/nhs-aws-helpers'
@@ -89,11 +90,14 @@ jobs:
8990
- name: merge into base_branch
9091
if: ${{ github.event_name == 'pull_request' }}
9192
run: |
92-
echo base branch "${{ github.base_ref }}"
93-
echo pr branch "${{ github.head_ref }}"
94-
git checkout "${{ github.base_ref }}"
93+
echo base branch "$BASE_BRANCH"
94+
echo pr branch "$PR_BRANCH"
95+
git checkout "$BASE_BRANCH"
9596
git checkout -b "merging-${{ github.event.number }}"
9697
git merge --ff-only "${{ github.event.pull_request.head.sha }}"
98+
env:
99+
BASE_BRANCH: ${{ github.base_ref }}
100+
PR_BRANCH: ${{ github.head_ref }}
97101

98102
- name: setup python
99103
uses: actions/setup-python@v5
@@ -158,16 +162,16 @@ jobs:
158162
- name: run sonar scan
159163
if: success() || failure()
160164
run: |
161-
PATH="$PWD/sonar-scanner/bin:$PATH"
162-
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
163-
git checkout "${GITHUB_HEAD_REF}"
164-
sonar-scanner -Dsonar.pullrequest.branch="{{ github.event.pull_request.head.sha }}" -Dsonar.pullrequest.base="{{ github.event.pull_request.base.sha }}" -Dsonar.pullrequest.key="${{ github.event.number }}"
165-
else
166-
sonar-scanner
167-
fi
165+
PATH="$PWD/sonar-scanner/bin:$PATH"
166+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
167+
git checkout "${GITHUB_HEAD_REF}"
168+
sonar-scanner -Dsonar.pullrequest.branch="{{ github.event.pull_request.head.sha }}" -Dsonar.pullrequest.base="{{ github.event.pull_request.base.sha }}" -Dsonar.pullrequest.key="${{ github.event.number }}"
169+
else
170+
sonar-scanner
171+
fi
168172
env:
169-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
170-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
173+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
174+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
171175

172176
- name: archive reports
173177
if: success() || failure()
@@ -206,11 +210,14 @@ jobs:
206210
- name: merge into base_branch
207211
if: ${{ github.event_name == 'pull_request' }}
208212
run: |
209-
echo base branch "${{ github.base_ref }}"
210-
echo pr branch "${{ github.head_ref }}"
211-
git checkout "${{ github.base_ref }}"
213+
echo base branch "$BASE_BRANCH"
214+
echo pr branch "$PR_BRANCH"
215+
git checkout "$BASE_BRANCH"
212216
git checkout -b "merging-${{ github.event.number }}"
213217
git merge --ff-only "${{ github.event.pull_request.head.sha }}"
218+
env:
219+
BASE_BRANCH: ${{ github.base_ref }}
220+
PR_BRANCH: ${{ github.head_ref }}
214221

215222
- name: setup python
216223
uses: actions/setup-python@v5
@@ -262,7 +269,6 @@ jobs:
262269
echo "RELEASE_VERSION=$version" >> $GITHUB_ENV
263270
echo "${version}"
264271
265-
266272
publish:
267273
runs-on: ubuntu-latest
268274
if: github.repository == 'NHSDigital/nhs-aws-helpers' && github.actor != 'dependabot[bot]'

0 commit comments

Comments
 (0)