-
Notifications
You must be signed in to change notification settings - Fork 69
53 lines (50 loc) · 1.78 KB
/
post_patch.yml
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
# Listen for successful "docs" workflow runs on pull requests,
# fetch the artifact containing the diff and PR number,
# create or update a comment containing the diff.
name: check_post_patch
on:
workflow_run:
workflows: ["docs"]
types:
- completed
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Checkout
uses: actions/checkout@v2
- name: Download artifacts
id: check-diff
shell: bash {0}
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}
run: |
python -m pip --disable-pip-version-check install requests
python ./.scripts/extract_diff.py ${{ github.event.workflow_run.artifacts_url }} ${{ secrets.GITHUB_TOKEN }}
if [ $? -eq 0 ]
then
echo "::set-output name=has-diff::true"
echo "::set-output name=pr-number::$(cat pr_number.txt)"
body=$(cat msg.txt)
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo "::set-output name=body::$body"
fi;
- name: Find existing comment
uses: peter-evans/find-comment@v1
id: find-comment
if: ${{ steps.check-diff.outputs.has-diff }}
with:
issue-number: ${{ steps.check-diff.outputs.pr-number }}
body-includes: GHA-event-listeners-diff
- name: Create PR comment
if: ${{ steps.check-diff.outputs.has-diff }}
uses: peter-evans/create-or-update-comment@v1
with:
edit-mode: replace
issue-number: ${{ steps.check-diff.outputs.pr-number }}
comment-id: ${{ steps.find-comment.outputs.comment-id }}
body: ${{ steps.check-diff.outputs.body }}