Skip to content

Commit 3932315

Browse files
author
Sunil Thaha
authored
Merge pull request #2297 from sustainable-computing-io/ci-comm-fx
ci: extract pr-number from the artifact
2 parents 1300ac1 + 890d232 commit 3932315

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

.github/workflows/config-change.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ jobs:
6969
echo "- manifests/helm/kepler/values.yaml"
7070
fi
7171
echo "EOF"
72-
} > /tmp/message.txt
72+
} > /tmp/message-${{ github.event.pull_request.number }}.txt
7373
7474
# NOTE: Uploading the message as an artifact so that PR Comment workflow can use it to
7575
# add comment on PR with the message.
7676
- name: Upload message
7777
uses: actions/upload-artifact@v4
7878
with:
7979
name: message
80-
path: /tmp/message.txt
80+
path: /tmp/message-${{ github.event.pull_request.number }}.txt
8181
retention-days: 1 # Keep artifact for 1 days

.github/workflows/pr-comment.yaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,18 @@ jobs:
3232
run-id: ${{ github.event.workflow_run.id }}
3333
github-token: ${{ secrets.GITHUB_TOKEN }}
3434

35-
- name: Comment on PR
35+
- name: Extract PR number from filename
3636
if: steps.download-artifact.outcome == 'success'
37+
id: extract-pr
38+
run: |
39+
echo "message-file=$(ls /tmp/message*.txt)" >> $GITHUB_OUTPUT
40+
echo "pr-number=$(echo /tmp/message*.txt | sed -E 's/.*message-([0-9]+)\.txt/\1/')" >> $GITHUB_OUTPUT
41+
42+
- name: Comment on PR
43+
if: steps.download-artifact.outcome == 'success' && steps.extract-pr.outputs.pr-number != ''
3744
uses: thollander/actions-comment-pull-request@v3
3845
with:
39-
file-path: /tmp/message.txt
46+
file-path: ${{ steps.extract-pr.outputs.message-file }}
4047
github-token: ${{ secrets.GITHUB_TOKEN }}
41-
pr-number: ${{ github.event.workflow_run.pull_requests[0].number }}
48+
pr-number: ${{ steps.extract-pr.outputs.pr-number }}
4249
reactions: eyes, rocket

.github/workflows/profiling.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,12 @@ jobs:
164164
echo "gh run download ${{ github.run_id }} -n profile-artifacts-${{ github.event.pull_request.number }}"
165165
echo "\`\`\`"
166166
echo ""
167-
} > /tmp/message.txt
167+
} > /tmp/message-${{ github.event.pull_request.number }}.txt
168168
# NOTE: Uploading the message as an artifact so that PR Comment workflow can use it to
169169
# add comment on PR with the message.
170170
- name: Upload message
171171
uses: actions/upload-artifact@v4
172172
with:
173173
name: message
174-
path: /tmp/message.txt
174+
path: /tmp/message-${{ github.event.pull_request.number }}.txt
175175
retention-days: 1 # Keep artifact for 1 days

0 commit comments

Comments
 (0)