-
Notifications
You must be signed in to change notification settings - Fork 37
60 lines (54 loc) · 1.64 KB
/
create-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
name: Create Pull Request
on:
workflow_call:
inputs:
repo:
description: "Repository in owner/repo format"
required: true
type: string
branch:
description: "Pull Request Branch"
required: true
type: string
pr-title:
description: "Pull Request Title"
required: true
type: string
asana-task-url:
description: "Asana Task URL"
required: true
type: string
secrets:
github-token:
required: true
outputs:
url:
description: "Pull Request URL"
value: ${{ jobs.create-pr.outputs.url }}
jobs:
create-pr:
runs-on: ubuntu-latest
outputs:
url: ${{ steps.create-pr.outputs.url }}
steps:
- name: Create PR Body
id: create-body
env:
GITHUB_TOKEN: ${{ secrets.github-token }}
run: |
pr_body_path=$(mktemp)
template="$(curl $(gh api https://api.github.com/repos/${{ inputs.repo }}/contents/.github/PULL_REQUEST_TEMPLATE.md --jq .download_url))"
sed <<< "$template" 's~\(Task.*URL:.*\)~\1 ${{ inputs.asana-task-url }}~' > "$pr_body_path"
echo "pr_body_path=${pr_body_path}" >> $GITHUB_OUTPUT
- name: Create iOS PR
id: create-pr
env:
GITHUB_TOKEN: ${{ secrets.github-token }}
run: |
url="$(gh pr create --repo ${{ inputs.repo }} \
--title "${{ inputs.pr-title }}" \
--body-file "${{ steps.create-body.outputs.pr_body_path }}" \
--assignee "${{ github.actor }}" \
--draft \
--head "${{ inputs.branch }}")"
echo "url=${url}" >> $GITHUB_OUTPUT