-
Notifications
You must be signed in to change notification settings - Fork 0
JIRA 이슈 링크 추가 방식 변경 #20
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,28 +27,19 @@ jobs: | |
| - name: Extract JIRA issue key from branch name | ||
| id: extract-jira-key | ||
| run: | | ||
| JIRA_KEY=$(echo ${{ github.head_ref }} | grep -oE 'MOD-[0-9]+' || echo "") | ||
| JIRA_KEY=$(echo ${{ github.head_ref }} | grep -oE 'MD-[0-9]+' || echo "") | ||
| echo "jira_key=$JIRA_KEY" >> "$GITHUB_OUTPUT" | ||
|
|
||
| # PR 본문을 JSON 형식으로 파싱하기 위한 jq 설치 | ||
| - name: Install jq | ||
| if: steps.extract-jira-key.outputs.jira_key != '' # JIRA 이슈 키가 없는 경우에는 실행하지 않음 | ||
| run: sudo apt-get update && sudo apt-get install -y jq | ||
|
Comment on lines
34
to
36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major
이전에 REST API PATCH 호출에서 JSON을 파싱하기 위해 ♻️ 제안하는 수정 방법- # PR 본문을 JSON 형식으로 파싱하기 위한 jq 설치
- - name: Install jq
- if: steps.extract-jira-key.outputs.jira_key != '' # JIRA 이슈 키가 없는 경우에는 실행하지 않음
- run: sudo apt-get update && sudo apt-get install -y jq
-🤖 Prompt for AI Agents |
||
|
|
||
| # https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#update-a-pull-request | ||
| - name: Add JIRA issue link to PR body | ||
| - name: Add JIRA issue link to Comment | ||
| if: steps.extract-jira-key.outputs.jira_key != '' # JIRA 이슈 키가 없는 경우에는 실행하지 않음 | ||
| run: | | ||
| PR_BODY=$(cat <<EOF | ||
| ${{ github.event.pull_request.body }} | ||
| EOF) | ||
| JIRA_KEY=${{ steps.extract-jira-key.outputs.jira_key }} | ||
| JIRA_LINK=$(printf "## 📝 관련 이슈\n\n[%s](%s/browse/%s)" "$JIRA_KEY" "${{ vars.JIRA_BASE_URL }}" "$JIRA_KEY") | ||
| UPDATED_BODY=$(printf "%s\n\n%s" "$JIRA_LINK" "$PR_BODY") | ||
| curl -L \ | ||
| -X PATCH \ | ||
| -H "Accept: application/vnd.github+json" \ | ||
| -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | ||
| -H "X-GitHub-Api-Version: 2022-11-28" \ | ||
| https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }} \ | ||
| -d "$(jq -n --arg body "$UPDATED_BODY" '{body: $body}')" | ||
| uses: thollander/actions-comment-pull-request@v3 | ||
| with: | ||
| message: | | ||
| ## 📝 관련 이슈 | ||
|
|
||
| [${{ steps.extract-jira-key.outputs.jira_key }}](${{ vars.JIRA_BASE_URL }}/browse/${{ steps.extract-jira-key.outputs.jira_key }}) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
github.head_ref를 직접 셸에 삽입하면 인젝션 위험이 있습니다.${{ github.head_ref }}는 사용자가 제어할 수 있는 값(브랜치 이름)이며, 따옴표 없이 셸 명령에 직접 삽입하면 특수 문자로 인한 셸 인젝션이 발생할 수 있습니다. 환경 변수를 통해 값을 전달하는 것이 안전합니다.🔒 제안하는 수정 방법
- name: Extract JIRA issue key from branch name id: extract-jira-key run: | - JIRA_KEY=$(echo ${{ github.head_ref }} | grep -oE 'MD-[0-9]+' || echo "") + JIRA_KEY=$(echo "$HEAD_REF" | grep -oE 'MD-[0-9]+' || echo "") echo "jira_key=$JIRA_KEY" >> "$GITHUB_OUTPUT" + env: + HEAD_REF: ${{ github.head_ref }}📝 Committable suggestion
🤖 Prompt for AI Agents