Skip to content

Commit

Permalink
Update create-jira-issue.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
hooni0918 authored Jun 25, 2024
1 parent 4bc4021 commit 7d3b511
Showing 1 changed file with 38 additions and 4 deletions.
42 changes: 38 additions & 4 deletions .github/workflows/create-jira-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,46 @@ jobs:
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" | sed 's/[^a-zA-Z0-9가-힣]//g')
TITLE_NO_PREFIX=$(echo "$ISSUE_TITLE" | sed -e "s/$PREFIX : //")
# iconv를 사용하여 비ASCII 문자 제거
CLEAN_TITLE=$(echo "$TITLE_NO_PREFIX" | iconv -c -f utf-8 -t ascii//TRANSLIT)
# ASCII가 아닌 문자 제거
CLEAN_TITLE=$(echo "$CLEAN_TITLE" | sed 's/[^a-zA-Z0-9]//g')
BRANCH_NAME="${PREFIX}/#${ISSUE_NUMBER}-${CLEAN_TITLE}"
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b "$BRANCH_NAME"
git push "https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}" "$BRANCH_NAME"
update_jira:
if: github.event_name == 'push'
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Update Jira issue with commit info
env:
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
JIRA_BASEURL: ${{ secrets.JIRA_BASEURL }}
JIRA_EMAIL: ${{ secrets.JIRA_EMAIL }}
JIRA_ISSUE_KEY: ${{ env.JIRA_ISSUE_KEY }}
run: |
COMMITS=$(jq -r '.commits[] | .message' $GITHUB_EVENT_PATH)
curl -D- \
-u "$JIRA_EMAIL:$JIRA_API_TOKEN" \
-X PUT \
--data '{
"update": {
"comment": [
{
"add": {
"body": "Commits related to this issue:\n$COMMITS"
}
]
]
}
}' \
-H "Content-Type: application/json" \
"$JIRA_BASEURL/rest/api/2/issue/$JIRA_ISSUE_KEY"

0 comments on commit 7d3b511

Please sign in to comment.