-
Notifications
You must be signed in to change notification settings - Fork 575
70 lines (62 loc) · 3.1 KB
/
auto-create-doc-issue-by-pr.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: PR Documentation Checker
on:
pull_request:
types:
- closed
- labeled
jobs:
check_pr_description:
runs-on: ubuntu-latest
steps:
- name: Check if PR is merged
id: check_merged
run: echo "merged=$(echo ${{ github.event.pull_request.merged }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Retrieve PR information
uses: 8BitJonny/gh-get-current-pr@2.2.0
id: PR
with:
sha: ${{ github.event.pull_request.head.sha }}
- name: Check if documentation update is needed
id: check_documentation_update
if: steps.PR.outputs.pr_found == 'true'
run: |
if [[ $PR_BODY == *"- [x] My PR needs documentation updates."* ]]; then
echo "documentation_update=true" >> $GITHUB_OUTPUT
elif [[ $PR_LABEL == *"user-facing-changes"* ]]; then
echo "documentation_update=true" >> $GITHUB_OUTPUT
elif [[ $PR_LABEL == *"breaking-change"* ]]; then
echo "documentation_update=true" >> $GITHUB_OUTPUT
else
echo "documentation_update=false" >> $GITHUB_OUTPUT
fi
env:
PR_BODY: ${{ steps.PR.outputs.pr_body }}
PR_LABEL: ${{ steps.PR.outputs.pr_labels }}
- name: Create issue in other repository
if: steps.check_merged.outputs.merged == 'true' && steps.check_documentation_update.outputs.documentation_update == 'true'
run: |
ISSUE_CONTENT="This issue tracks the documentation update needed for the merged PR #$PR_ID.\n\nSource PR URL: $PR_URL\nSource PR Merged At: $PR_MERGED_AT\n\nIf it is a major improvement that deserves a new page or a new section in the documentation, please check if we should label it as an experiment feature."
curl -X POST \
-H "Authorization: Bearer ${{ secrets.ACCESS_TOKEN }}" \
-d "{\"title\": \"Document: $PR_TITLE\",\"body\": \"$ISSUE_CONTENT\"}" \
"https://api.github.com/repos/risingwavelabs/risingwave-docs/issues"
env:
PR_ID: ${{ steps.PR.outputs.number }}
PR_URL: ${{ steps.PR.outputs.pr_url }}
PR_TITLE: ${{ steps.PR.outputs.pr_title }}
PR_BODY: ${{ steps.PR.outputs.pr_body }}
PR_CREATED_AT: ${{ steps.PR.outputs.pr_created_at }}
PR_MERGED_AT: ${{ steps.PR.outputs.pr_merged_at }}
PR_CLOSED_AT: ${{ steps.PR.outputs.pr_closed_at }}
PR_LABEL: ${{ steps.PR.outputs.pr_labels }}
- name: print_output_variables
run: |
echo "Merged: ${{ steps.check_merged.outputs.merged }}"
echo "PR ID: ${{ steps.PR.outputs.number }}"
echo "PR URL: ${{ steps.PR.outputs.pr_url }}"
echo "PR Title: ${{ steps.PR.outputs.pr_title }}"
echo "PR Created At: ${{ steps.PR.outputs.pr_created_at }}"
echo "PR Merged At: ${{ steps.PR.outputs.pr_merged_at }}"
echo "PR Closed At: ${{ steps.PR.outputs.pr_closed_at }}"
echo "PR Labels: ${{ steps.PR.outputs.pr_labels }}"
echo "Documentation Update: ${{ steps.check_documentation_update.outputs.documentation_update }}"