Skip to content

Commit

Permalink
ブランチ自動生成 (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
ttizze authored Jul 25, 2024
1 parent 0aafd3e commit bac6d93
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/create-branch-on-issue-assign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Create Branch on Issue Assign

on:
issues:
types: [assigned]

jobs:
create_branch:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Create branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
ISSUE_TITLE: ${{ github.event.issue.title }}
ASSIGNEE: ${{ github.event.assignee.login }}
run: |
LABELS=$(gh issue view $ISSUE_NUMBER --json labels -q '.labels[].name')
for LABEL in $LABELS; do
case $LABEL in
"feature") TYPE="feat"; break ;;
"bug") TYPE="fix"; break ;;
"documentation") TYPE="docs"; break ;;
"refactor") TYPE="refactor"; break ;;
"chore") TYPE="chore"; break ;;
esac
done
BRANCH_NAME="${ASSIGNEE,,}/issue-${ISSUE_NUMBER}-${TYPE}"
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git checkout -b "$BRANCH_NAME"
git push origin "$BRANCH_NAME"
gh issue comment $ISSUE_NUMBER --body "created branch \`$BRANCH_NAME\`"

0 comments on commit bac6d93

Please sign in to comment.