Skip to content

Commit

Permalink
feat: pr issue close workflow 생성 (#328)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arachneee authored Aug 13, 2024
1 parent e47972a commit eb5d9ce
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/pr-issue-close.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Close Issue on PR Merge

on:
pull_request:
types: [closed]

jobs:
close-issue:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Extract issue number from PR body
id: extract_issue
run: |
# Fetch PR body
PR_BODY=$(curl -s -H "Authorization: token ${{ secrets.CONFIG_SUBMODULE_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}" \
| jq -r '.body')
# Extract issue number from PR body using regex (customize if needed)
ISSUE_NUMBER=$(echo "$PR_BODY" | grep -oP '#\d+' | head -1 | sed 's/#//')
echo "ISSUE_NUMBER=$ISSUE_NUMBER" >> $GITHUB_ENV
- name: Close associated issue
if: env.ISSUE_NUMBER != ''
run: |
echo "Closing issue #${{ env.ISSUE_NUMBER }}"
curl -s -X PATCH -H "Authorization: token ${{ secrets.CONFIG_SUBMODULE_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-d '{"state": "closed"}' \
"https://api.github.com/repos/${{ github.repository }}/issues/${{ env.ISSUE_NUMBER }}"

0 comments on commit eb5d9ce

Please sign in to comment.