Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: issue id in create branch script 12 #15

Merged
merged 3 commits into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
> Always leave the code behind in a better state than you found it.
Closes #<ISSUE_ID>
> Always leave the code behind in a better state than you found it.
28 changes: 0 additions & 28 deletions .github/workflow/link-pr-issue.yml

This file was deleted.

46 changes: 46 additions & 0 deletions .github/workflows/link-pr-issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: link pr to issue

on:
pull_request:
types: [opened, edited, reopened]
branch_protection_rule:
types: [edited]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
link-issue:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Extract branch name
shell: bash
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
run: |
issue_id=$(echo ${{ env.BRANCH_NAME }} | grep -oE '[0-9]+$')
echo "issue_id=$issue_id" >> $GITHUB_ENV

- name: Check if Issue ID Exists
id: check
run: |
if [ -z "${{ env.issue_id }}" ]; then
echo "No issue ID found in branch name."
exit 1
fi

- name: Update PR Description
if: steps.check.outcome == 'success'
env:
GH_TOKEN: ${{ github.token }}
run: |
gh pr edit ${{ github.event.pull_request.number }} --body "$(cat << EOF
> Always leave the code behind in a better state than you found it.

Closes #${{ env.issue_id }}
EOF
)"
6 changes: 5 additions & 1 deletion tools/scripts/create-branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ read -p "Your choice: " choice

read -p "Enter the branch name: " branch_name

read -p "Enter the issue id: " issue_id

case $choice in
1)
prefix="feat"
Expand All @@ -34,7 +36,9 @@ case $choice in
;;
esac

full_branch_name="${prefix}/${branch_name}"
branch_name_with_hyphen=$(echo "$branch_name" | sed 's/ /-/g')

full_branch_name="${prefix}/${branch_name_with_hyphen}-${issue_id}"

git checkout -b "$full_branch_name"

Expand Down
Loading