41 lines
1.3 KiB
YAML
41 lines
1.3 KiB
YAML
name: Create Branch on Issue Transition to In Progress
|
|
|
|
on:
|
|
issues:
|
|
types:
|
|
- edited
|
|
|
|
jobs:
|
|
create-branch:
|
|
if: github.event.changes.issue.labels
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Get issue details
|
|
run: |
|
|
issue_title=$(jq -r ".issue.number" "$GITHUB_EVENT_PATH")
|
|
previous_labels=$(jq -r ".changes.labels.from" "$GITHUB_EVENT_PATH")
|
|
current_labels=$(jq -r ".issue.labels | map(.name) | join(\", \")" "$GITHUB_EVENT_PATH")
|
|
branch_name=""
|
|
|
|
# Check if the issue transitioned from 'Todo' to 'In Progress'
|
|
if [[ "$previous_labels" == *"Todo"* && "$current_labels" == *"In Progress"* ]]; then
|
|
project_name="hp-be" # Verwende "hp-be" als Projektnamen
|
|
branch_name="${project_name}-${issue_title}"
|
|
echo "Branch name: $branch_name"
|
|
fi
|
|
|
|
echo "::set-output name=branch_name::$branch_name"
|
|
shell: bash
|
|
|
|
- name: Create and switch to new branch
|
|
run: |
|
|
branch_name="${{ steps.create-branch.outputs.branch_name }}"
|
|
if [ -n "$branch_name" ]; then
|
|
git checkout -b "$branch_name"
|
|
git push origin "$branch_name"
|
|
fi
|
|
working-directory: ${{ github.workspace }}
|