forked from tscircuit/tscircuit-autorouter
-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (66 loc) · 2.53 KB
/
create-bug-report.yml
File metadata and controls
81 lines (66 loc) · 2.53 KB
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
name: Create Bug Report
on:
workflow_dispatch:
inputs:
bug_report_url:
description: "Bug report URL or UUID"
required: true
type: string
jobs:
create-bug-report:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 1.3.1
- name: Install dependencies
run: bun install
- name: Run bug report script
id: bug_report
run: |
output=$(bun run bug-report-with-test "${{ github.event.inputs.bug_report_url }}" 2>&1)
echo "$output"
# Extract bug report number from output
bug_num=$(echo "$output" | grep -oP 'Bug report "\K\d+' || echo "")
echo "bug_number=$bug_num" >> $GITHUB_OUTPUT
- name: Get created files info
id: files_info
run: |
# Find the bug report number from the new test file
test_file=$(git status --porcelain | grep "tests/bugs/bugreport" | head -1 | awk '{print $2}')
if [ -n "$test_file" ]; then
bug_num=$(echo "$test_file" | grep -oP 'bugreport\K\d+')
echo "bug_number=$bug_num" >> $GITHUB_OUTPUT
echo "test_file=$test_file" >> $GITHUB_OUTPUT
fi
- name: Create branch and commit
id: create_branch
run: |
bug_num="${{ steps.files_info.outputs.bug_number }}"
branch_name="bugreport${bug_num}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b "$branch_name"
git add .
git commit -m "add bugreport${bug_num}"
git push origin "$branch_name"
echo "branch_name=$branch_name" >> $GITHUB_OUTPUT
- name: Create Pull Request
id: create_pr
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
bug_num="${{ steps.files_info.outputs.bug_number }}"
branch_name="${{ steps.create_branch.outputs.branch_name }}"
pr_url=$(gh pr create \
--title "Add bug report ${bug_num}" \
--body "Automatically created bug report from URL: ${{ github.event.inputs.bug_report_url }}" \
--head "$branch_name" \
--base main)
echo "pr_url=$pr_url" >> $GITHUB_OUTPUT
echo ""
echo "=========================================="
echo "Pull Request created: $pr_url"
echo "=========================================="