-
Notifications
You must be signed in to change notification settings - Fork 2
126 lines (106 loc) · 4.28 KB
/
issue_to_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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: Issue to Pull Request
on:
issues:
types:
- opened
- edited
- reopened
permissions:
contents: write
issues: write
pull-requests: write
jobs:
validate:
name: Validate .properties File and Create a submission Pull Request
# Only run this job if the issue has the 'new contribution' label
if: contains(github.event.issue.labels.*.name, 'new contribution')
runs-on: ubuntu-latest
env:
BRANCH_NAME: issue-${{ github.event.issue.number }}
ISSUE_NUM: ${{ github.event.issue.number }}
ISSUE_TITLE: ${{ github.event.issue.title }}
steps:
- name: Parse issue
id: parseIssue
uses: onmax/[email protected]
with:
issue_number: ${{ github.event.issue.number }}
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install dependencies
run: pip install -r requirements.txt
- name: Read and validate properties txt file
id: parseProps
run: |
python -u scripts/parse_and_validate_properties_txt.py \
"${{ contains(github.event.issue.labels.*.name, 'library') && 'library' ||
contains(github.event.issue.labels.*.name, 'tools') && 'tool' ||
contains(github.event.issue.labels.*.name, 'mode') && 'mode' ||
contains(github.event.issue.labels.*.name, 'examples') && 'examples' }}" \
"${{ fromJson(steps.parseIssue.outputs.payload)['Properties File URL'] }}"
- name: add comment to issue
id: issueComment
if: success()
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.issue.number }}
body: |
Your properties file was successfully parsed.
- name: if failure, add comment to issue
if: failure()
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.issue.number }}
body: |
There was an error in reading your properties file or parsing it.
Please ensure that the URL is correct and the file follows the required format.
${{ steps.parseProps.outputs.error }}
- name: check if target branch exists
id: branchExists
uses: GuillaumeFalourd/branch-exists@v1
with:
branch: ${{ env.BRANCH_NAME }}
- name: delete target branch if exists
if: steps.branchExists.outputs.exists == 'true'
uses: dawidd6/action-delete-branch@v3
with:
github_token: ${{github.token}}
branches: ${{ env.BRANCH_NAME }}
- name: create branch
env:
GH_TOKEN: ${{ github.token }}
run: gh issue develop $ISSUE_NUM --name $BRANCH_NAME --checkout
- name: edit database
run: |
cd scripts
python add_new_contribution_to_yaml.py '${{ steps.parseProps.outputs.props }}'
- name: commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: adding contribution ${{ github.event.issue.title }} from #${{ github.event.issue.number }}
branch: ${{ env.BRANCH_NAME }}
add_options: '-u'
- name: Create pull request
run: |
gh pr create -B main -H $BRANCH_NAME --title "Adding ${{ github.event.issue.title }}" --body "This pull request will add ${{ github.event.issue.title }}
and it closes \#${{ github.event.issue.number }}"
env:
GH_TOKEN: ${{ github.token }}
- name: add comment to issue
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.issueComment.outputs.comment-id }}
body: |
A pull request with your contribution has been successfully created.
- name: if failure, add comment to issue
if: failure()
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.issueComment.outputs.comment-id }}
body: |
An error was encountered when adding your contribution.
We will look into this issue as soon as possible. Please check the details of your submission and try again if necessary.