-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (52 loc) · 1.77 KB
/
branch-creation.yml
File metadata and controls
61 lines (52 loc) · 1.77 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
name: Automated Branch Creation
on:
issues:
types: [opened]
jobs:
create-branch:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout the repository
uses: actions/checkout@v3
- name: Extract issue details
id: extract_issue
run: |
issue_title=$(echo "${{ github.event.issue.title }}" | tr ' ' '-' | tr -dc '[:alnum:]-')
# Determine the issue type based on the label
issue_type=""
for label in "${{ github.event.issue.labels[*] }}"; do
case "$label" in
"⚙️ Efficiency & Performance")
issue_type="efficiency"
;;
"✨ Feature Request")
issue_type="feature"
;;
"🐛 Bug Report" | "⚠️ Security Vulnerability")
issue_type="bug"
;;
"📝 Documentation")
issue_type="documentation"
;;
"🤔 Support or Usage Questions")
issue_type="support"
;;
esac
done
# Fallback in case no matching label is found
if [ -z "$issue_type" ]; then
issue_type="misc"
fi
echo "issue_title=$issue_title" >> $GITHUB_ENV
echo "issue_type=$issue_type" >> $GITHUB_ENV
- name: Create branch name
id: branch_name
run: echo "branch_name=${{ env.issue_type }}/REACT-FRAMIFY-${{ env.issue_title }}" >> $GITHUB_ENV
- name: Create and push branch
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email 'actions@github.com'
git checkout -b ${{ env.branch_name }} || git checkout ${{ env.branch_name }}
git push origin ${{ env.branch_name }}