-
Notifications
You must be signed in to change notification settings - Fork 0
36 lines (32 loc) · 1.15 KB
/
auto-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
name: Auto open pull request on puzzle branches
on:
push:
branches:
- 'puzzle/**'
jobs:
open-pull-request:
runs-on: ubuntu-latest
steps:
- name: get issue number
id: get_issue_number
run: |
if [[ ${{ github.ref_name }} =~ puzzle/([0-9]{4})-day-([1-9]|1[0-9]|2[0-5]) ]]; then
year=${BASH_REMATCH[1]}
day=${BASH_REMATCH[2]}
issue_number=$(gh issue list -S '[$year] [Day $day] in:title' --json number | jq '.[].number')
if [ -z "$issue_number" ]; then
echo "::error::Issue not found!"
exit 1
else
echo "issue_number=${issue_number}" >> $GITHUB_OUTPUT
fi
else
echo "::error::Branch does not match the expected pattern"
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }}
- name: create pull request
run: gh pr create -B ${{ GITHUB_DEFAULT_BRANCH }} -H ${{ github.ref_name }} --title 'Pull request to resolve #${{ steps.get_issue_number.outputs.issue_number }}'
env:
GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }}