You've already forked devops-pipeline-template
Fix GITHUB_TOKEN environment variable and update issue closing method to use Gitea API
This commit is contained in:
@@ -17,7 +17,7 @@ jobs:
|
||||
|
||||
- name: Extract issue number and close issue
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
|
||||
echo "Branch name: $BRANCH_NAME"
|
||||
@@ -27,8 +27,20 @@ jobs:
|
||||
ISSUE_NUMBER="${BASH_REMATCH[1]}"
|
||||
echo "Found issue number: $ISSUE_NUMBER"
|
||||
|
||||
# Close the issue
|
||||
gh issue close "$ISSUE_NUMBER" --comment "Automatically closed by PR #${{ github.event.pull_request.number }}"
|
||||
# Close the issue using Gitea API
|
||||
curl -X PATCH \
|
||||
-H "Authorization: token ${GITHUB_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"state":"closed"}' \
|
||||
"${{ github.api_url }}/repos/${{ github.repository }}/issues/${ISSUE_NUMBER}"
|
||||
|
||||
# Add a comment
|
||||
curl -X POST \
|
||||
-H "Authorization: token ${GITHUB_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"body\":\"Automatically closed by PR #${{ github.event.pull_request.number }}\"}" \
|
||||
"${{ github.api_url }}/repos/${{ github.repository }}/issues/${ISSUE_NUMBER}/comments"
|
||||
|
||||
echo "Issue #$ISSUE_NUMBER has been closed"
|
||||
else
|
||||
echo "Branch name does not match expected format (issue-NUMBER-title)"
|
||||
|
||||
Reference in New Issue
Block a user