From 8fed3af7f4f47db673568f1f35fcde290258b4a4 Mon Sep 17 00:00:00 2001 From: YIZIHN Date: Mon, 1 Jul 2024 01:30:50 +0900 Subject: [PATCH] =?UTF-8?q?Update=20create-jira-issue.yml=E3=85=87?= =?UTF-8?q?=E3=85=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/create-jira-issue.yml | 54 +++++-------------------- 1 file changed, 10 insertions(+), 44 deletions(-) diff --git a/.github/workflows/create-jira-issue.yml b/.github/workflows/create-jira-issue.yml index 33368dc2..60ce07c3 100644 --- a/.github/workflows/create-jira-issue.yml +++ b/.github/workflows/create-jira-issue.yml @@ -1,69 +1,35 @@ -name: Create Jira Issue and Sync with GitHub +name: Create Branch from Issue on: issues: types: [opened] jobs: - create_jira_issue: - if: github.event_name == 'issues' + create_branch: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v2 - with: - ref: 'suyeon' # 'suyeon' 브랜치를 기준으로 체크아웃 - - name: Create Jira issue - env: - JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} - JIRA_BASEURL: ${{ secrets.JIRA_BASEURL }} - JIRA_EMAIL: ${{ secrets.JIRA_EMAIL }} - JIRA_PROJECT_KEY: ${{ secrets.JIRA_PROJECT_KEY }} + - name: Setup Git Config run: | - ISSUE_TITLE="${{ github.event.issue.title }}" - - JSON_DATA=$(jq -n \ - --arg key "$JIRA_PROJECT_KEY" \ - --arg summary "$ISSUE_TITLE" \ - '{ - "fields": { - "project": { - "key": $key - }, - "summary": $summary, - "description": "No description provided.", - "issuetype": { - "name": "Task" - } - } - }') + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" - echo "JSON Data: $JSON_DATA" - RESPONSE=$(curl -D- \ - -u "$JIRA_EMAIL:$JIRA_API_TOKEN" \ - -X POST \ - --data "$JSON_DATA" \ - -H "Content-Type: application/json" \ - "$JIRA_BASEURL/rest/api/2/issue/") - echo "Jira API response: $RESPONSE" - JIRA_ISSUE_KEY=$(echo "$RESPONSE" | grep -oP '(?<=key\":\")\w+-\d+') - echo "JIRA_ISSUE_KEY=$JIRA_ISSUE_KEY" >> $GITHUB_ENV - - - name: Create GitHub branch based on issue + - name: Create branch for the issue env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | ISSUE_NUMBER=${{ github.event.issue.number }} ISSUE_TITLE="${{ github.event.issue.title }}" + # 접두사 추출 PREFIX=$(echo "$ISSUE_TITLE" | grep -oE '^(feat|fix|docs|setting|add|refactor|chore)') if [ -z "$PREFIX" ]; then PREFIX="feature"; fi - TITLE_NO_PREFIX=$(echo "$ISSUE_TITLE" | sed -e "s/$PREFIX : //") - CLEAN_TITLE=$(echo "$TITLE_NO_PREFIX" | iconv -c -f utf-8 -t ascii//TRANSLIT | sed 's/[^a-zA-Z0-9]//g') - BRANCH_NAME="${PREFIX}-${ISSUE_NUMBER}-${CLEAN_TITLE}" + # 브랜치 이름 생성 + BRANCH_NAME="${PREFIX}/#${ISSUE_NUMBER}-$(echo "$ISSUE_TITLE" | iconv -c -f utf-8 -t ascii//TRANSLIT | sed 's/[^a-zA-Z0-9-]//g')" echo "Creating branch with name: $BRANCH_NAME" - + git branch git status