Redshift ELT #405
This file contains 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
name: Auto Close Issue when all tasks are completed | |
on: | |
issues: | |
types: [opened, edited] | |
jobs: | |
check-tasks-and-close-issue: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
issues: write | |
steps: | |
# 이슈 | |
- name: Check for Tasklist in Issue Description | |
id: check-tasklist | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
ISSUE_NUMBER: ${{ github.event.issue.number }} | |
run: | | |
# 이슈 본문 가져오기 | |
ISSUE_BODY=$(curl -s \ | |
-H "Authorization: Bearer $GITHUB_TOKEN" \ | |
-H "Accept: application/vnd.github+json" \ | |
"https://api.github.com/repos/${{ github.repository }}/issues/$ISSUE_NUMBER" | jq -r '.body') | |
# Tasklist 항목 추출 및 로그 출력 | |
echo "Extracted Tasklist from Issue Description:" | |
echo "$ISSUE_BODY" | grep -E '\- \[ \]|\- \[x\]' | |
echo "---------------------------------------------" | |
# Tasklist 항목 확인 | |
TOTAL_TASKS=$(echo "$ISSUE_BODY" | grep -o -E '\- \[[ x]\]' | wc -l) | |
COMPLETED_TASKS=$(echo "$ISSUE_BODY" | grep -o -E '\- \[x\]' | wc -l) | |
# Tasklist가 있고 모든 항목이 완료된 경우 | |
if [ "$TOTAL_TASKS" -gt 0 ] && [ "$TOTAL_TASKS" -eq "$COMPLETED_TASKS" ]; then | |
echo "All tasks in the issue description are completed." | |
echo "::set-output name=all_tasks_completed::true" | |
else | |
echo "Not all tasks in the issue description are completed or no tasks found." | |
echo "::set-output name=all_tasks_completed::false" | |
fi | |
- name: Close Issue | |
if: steps.check-tasklist.outputs.all_tasks_completed == 'true' | |
uses: peter-evans/close-issue@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
issue-number: ${{ github.event.issue.number }} | |
comment: "Auto-closing this issue because all tasks have been completed." |