forked from zephyrproject-rtos/ArduinoCore-zephyr
-
Notifications
You must be signed in to change notification settings - Fork 55
55 lines (46 loc) · 1.7 KB
/
leave_pr_comment.yml
File metadata and controls
55 lines (46 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Copyright (c) Arduino s.r.l. and/or its affiliated companies
# SPDX-License-Identifier: Apache-2.0
name: Leave PR comment
on:
workflow_run:
workflows: ["Package, test and upload core"]
types:
- completed
permissions:
contents: read
pull-requests: write
jobs:
comment-on-pr:
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: dawidd6/action-download-artifact@ac66b43f0e6a346234dd65d4d0c8fbb31cb316e5 # v11
with:
workflow: package-core.yml
run_id: ${{ github.event.workflow_run.id }}
name: comment-request
if_no_artifact_found: ignore
- name: Load PR number
run: |
echo "PR_NUM=$(cat pr_number || true)" >> $GITHUB_ENV
- name: Check PR number
id: check-pr
uses: carpentries/actions/check-valid-pr@2e20fd5ee53b691e27455ce7ca3b16ea885140e8 # v0.15.0
if: ${{ env.PR_NUM }}
with:
pr: ${{ env.PR_NUM }}
sha: ${{ github.event.workflow_run.head_sha }}
- name: Validate PR number
if: ${{ env.PR_NUM && steps.check-pr.outputs.VALID != 'true' }}
run: |
echo "::warning::PR #$PR_NUM is either invalid or includes changes to workflow"
- name: Update PR comment
if: ${{ env.PR_NUM && steps.check-pr.outputs.VALID == 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
run: |
BODY="$(cat comment_body || echo '# :fire: CI failure processing logs!')"
# delete existing comment, if present, then add a new one
gh pr comment ${PR_NUM} --delete-last --yes || true
gh pr comment ${PR_NUM} --body "${BODY}"