@@ -9,23 +9,20 @@ defaults:
99 shell : bash
1010
1111permissions :
12- contents : write
13- issues : read
14- pull-requests : write
15- checks : write
12+ contents : read
1613
1714jobs :
1815 assign-hip-number :
1916 runs-on : hiero-improvement-proposals-linux-medium
2017 continue-on-error : true # Silently fail - don't show red X on PRs
2118 steps :
2219 - name : Harden Runner
23- uses : step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
20+ uses : step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0
2421 with :
2522 egress-policy : audit
2623
2724 - name : Checkout Code
28- uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 .0.2
25+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 .0.1
2926 with :
3027 token : ${{ secrets.GH_ACCESS_TOKEN }}
3128 fetch-depth : 0
5249
5350 # Directory path to check for HIP files
5451 HIP_DIRECTORY='HIP'
55- HIP_FILES=$(echo "$MODIFIED_FILES" | grep "^$HIP_DIRECTORY/.*\.md")
52+ HIP_FILES=$(echo "$MODIFIED_FILES" | grep "^$HIP_DIRECTORY/.*\.md" || true )
5653 echo "Filtered HIP files: $HIP_FILES"
5754 echo "::set-output name=hip-files::$HIP_FILES"
5855
@@ -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,26 +97,37 @@ 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
107- if [ -n "$HIP_FILE" ]; then
108- NEW_HIP_FILE="HIP/hip-$PR_NUMBER.md"
109- mv "$HIP_FILE" "$NEW_HIP_FILE"
110- else
106+ if [ -z "$HIP_FILE" ]; then
111107 echo "No HIP file found to rename. Skipping rename."
112108 exit 0
113109 fi
114110
111+ NEW_HIP_FILE="HIP/hip-$PR_NUMBER.md"
112+
113+ # Skip the rename when the file is already correctly named; otherwise
114+ # `mv <same> <same>` exits non-zero and aborts the remaining steps.
115+ if [ "$HIP_FILE" = "$NEW_HIP_FILE" ]; then
116+ echo "HIP file already has expected name ($NEW_HIP_FILE). Skipping rename."
117+ exit 0
118+ fi
119+
120+ mv "$HIP_FILE" "$NEW_HIP_FILE"
121+
115122 - name : Commit Changes
116123 if : steps.check-new.outputs.new-hip == 'true'
124+ env :
125+ PR_NUMBER : ${{ github.event.pull_request.number }}
126+ HEAD_REF : ${{ github.head_ref }}
117127 run : |
118128 git config --global user.name 'GitHub Action'
119129 git config --global user.email 'action@github.com'
120130
121- PR_NUMBER=${{ github.event.pull_request.number }}
122131 git add HIP/
123132
124133 # Check if there are changes to commit
@@ -132,7 +141,7 @@ jobs:
132141 exit 0
133142 }
134143
135- git push origin HEAD:${{ github.head_ref }} || {
144+ git push origin " HEAD:$HEAD_REF" || {
136145 echo "Push failed. This is expected for PRs from forks without write access."
137146 echo "The PR author will need to manually update their branch."
138147 exit 0
0 commit comments