forked from joomlatools/joomlatools-console
-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (42 loc) · 1.94 KB
/
pull-request.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
name: Create a pull request
on:
create:
jobs:
pull-request:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Only run on branches whose names start with feature/ or hotfix/
if: startsWith(github.ref, 'refs/heads/feature') || startsWith(github.ref, 'refs/heads/hotfix')
shell: bash
run: echo "ISSUE_ID=$(echo $GITHUB_REF | grep -o -E '[0-9]+' | head -1 | sed -e 's/^0\+//')" >> $GITHUB_ENV
- name: Get issue data
uses: octokit/[email protected]
if: ${{ env.ISSUE_ID }}
id: issue
with:
route: GET /repos/${{ github.repository }}/issues/${{ env.ISSUE_ID }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Gather PR data
if: ${{ steps.issue.outputs.data }}
id: pr_data
shell: bash
run: |
echo "::set-output name=title::$(echo $json_var | jq '.title' --raw-output )"
echo "::set-output name=body::Closes #$(echo $json_var | jq '.number' --raw-output)"
echo "::set-output name=assignee::$(echo $json_var | jq '[.assignees[].login] | join(",")' --raw-output --compact-output)"
echo "::set-output name=label::$(echo $json_var | jq '[.labels[].name] | join(",")' --raw-output --compact-output)"
echo "::set-output name=milestone::$(echo $json_var | jq '[.milestone.title] | join(",")' --raw-output --compact-output)"
env:
json_var: ${{ steps.issue.outputs.data }}
- name: Create pull request
if: ${{ steps.issue.outputs.data }}
uses: repo-sync/pull-request@v2
with:
pr_title: ${{ steps.pr_data.outputs.title }}
pr_body: ${{ steps.pr_data.outputs.body }}
pr_assignee: ${{ steps.pr_data.outputs.assignee }}
pr_label: ${{ steps.pr_data.outputs.label }}
pr_milestone: ${{ steps.pr_data.outputs.milestone }}
github_token: ${{ secrets.GITHUB_TOKEN }}