Skip to content

Commit c264c33

Browse files
authored
ci: harden GitHub Actions for OpenSSF Scorecard (#1509)
Signed-off-by: Michael Garber <michael.garber@hashgraph.com>
1 parent 82eeb28 commit c264c33

5 files changed

Lines changed: 22 additions & 20 deletions

File tree

.github/workflows/add-hip-number.yml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ defaults:
99
shell: bash
1010

1111
permissions:
12-
contents: write
13-
issues: read
14-
pull-requests: write
15-
checks: write
12+
contents: read
1613

1714
jobs:
1815
assign-hip-number:
@@ -82,11 +79,12 @@ jobs:
8279
8380
- name: Assign HIP Number
8481
if: steps.check-new.outputs.new-hip == 'true'
82+
env:
83+
PR_NUMBER: ${{ github.event.pull_request.number }}
84+
HIP_FILES: ${{ steps.check-new.outputs.hip-files }}
8585
run: |
86-
# Extract the current PR number
87-
PR_NUMBER=${{ github.event.pull_request.number }}
8886
HIP_HEADER="hip: $PR_NUMBER"
89-
HIP_FILE=$(echo "${{ steps.check-new.outputs.hip-files }}" | head -n 1)
87+
HIP_FILE=$(echo "$HIP_FILES" | head -n 1)
9088
9189
echo "Assigning HIP number to file: $HIP_FILE"
9290
@@ -99,10 +97,11 @@ jobs:
9997
10098
- name: Rename HIP File
10199
if: steps.check-new.outputs.new-hip == 'true'
100+
env:
101+
PR_NUMBER: ${{ github.event.pull_request.number }}
102+
HIP_FILES: ${{ steps.check-new.outputs.hip-files }}
102103
run: |
103-
# Extract PR number
104-
PR_NUMBER=${{ github.event.pull_request.number }}
105-
HIP_FILE=$(echo "${{ steps.check-new.outputs.hip-files }}" | head -n 1)
104+
HIP_FILE=$(echo "$HIP_FILES" | head -n 1)
106105
107106
if [ -z "$HIP_FILE" ]; then
108107
echo "No HIP file found to rename. Skipping rename."
@@ -122,11 +121,13 @@ jobs:
122121
123122
- name: Commit Changes
124123
if: steps.check-new.outputs.new-hip == 'true'
124+
env:
125+
PR_NUMBER: ${{ github.event.pull_request.number }}
126+
HEAD_REF: ${{ github.head_ref }}
125127
run: |
126128
git config --global user.name 'GitHub Action'
127129
git config --global user.email 'action@github.com'
128130
129-
PR_NUMBER=${{ github.event.pull_request.number }}
130131
git add HIP/
131132
132133
# Check if there are changes to commit
@@ -140,7 +141,7 @@ jobs:
140141
exit 0
141142
}
142143
143-
git push origin HEAD:${{ github.head_ref }} || {
144+
git push origin "HEAD:$HEAD_REF" || {
144145
echo "Push failed. This is expected for PRs from forks without write access."
145146
echo "The PR author will need to manually update their branch."
146147
exit 0

.github/workflows/notifications.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
name: Dispatch Status Change Notifications (discord and email)
22
permissions:
3-
contents: read
4-
actions: write
3+
contents: read
54
on:
65
push:
76
branches:
@@ -13,6 +12,9 @@ defaults:
1312
jobs:
1413
DispatchNotifications:
1514
runs-on: hiero-improvement-proposals-linux-medium
15+
permissions:
16+
contents: read
17+
actions: write
1618
steps:
1719
- name: Harden Runner
1820
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4

.github/workflows/schedule-last-call-date-end.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
name: Schedule Status Update Based on Last Call Time
22

33
permissions:
4-
pull-requests: write
5-
contents: write
6-
packages: write
4+
contents: read
75

86
defaults:
97
run:
@@ -19,6 +17,9 @@ jobs:
1917
check-merged-file:
2018
if: github.event.pull_request.merged == true
2119
runs-on: hiero-improvement-proposals-linux-medium
20+
permissions:
21+
contents: write
22+
pull-requests: write
2223

2324
steps:
2425
- name: Harden Runner

.github/workflows/send-discord-message.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ on:
1313

1414
permissions:
1515
contents: read
16-
actions: write
1716

1817
defaults:
1918
run:

.github/workflows/update-draft-hips.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ jobs:
1313
if: ${{ github.ref == 'refs/heads/main' }} # Only run on main branch
1414
runs-on: hiero-improvement-proposals-linux-medium
1515
permissions:
16-
contents: write
17-
pull-requests: read
16+
contents: read
1817
steps:
1918
- name: Harden the runner (Audit all outbound calls)
2019
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4

0 commit comments

Comments
 (0)