-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (56 loc) · 2.39 KB
/
TodoClosed.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: Issue Closed
on:
issues:
types: [closed]
jobs:
create-md:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
ref: main
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Create issue markdown file
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
ISSUE_NUMBER="${{ github.event.issue.number }}"
ISSUE_TITLE="${{ github.event.issue.title }}"
ISSUE_BODY="${{ github.event.issue.body }}"
ISSUE_USER="${{ github.event.issue.user.login }}"
REPO_FULL_NAME="${{ github.repository }}"
# 파일명으로 사용할 수 없는 문자 제거 및 변환
SANITIZED_ISSUE_TITLE=$(echo "${ISSUE_TITLE}" | tr ' ' '-' | tr -cd 'a-zA-Z0-9가-힣-')
# 만약 SANITIZED_ISSUE_TITLE이 비어있다면 기본값 사용
if [ -z "$SANITIZED_ISSUE_TITLE" ]; then
SANITIZED_ISSUE_TITLE="issue-${ISSUE_NUMBER}"
fi
FILE_NAME="TodoList/${SANITIZED_ISSUE_TITLE}.md"
mkdir -p TodoList
echo "# Issue #${ISSUE_NUMBER}: ${ISSUE_TITLE}" > "$FILE_NAME"
echo "" >> "$FILE_NAME"
echo "${ISSUE_BODY}" >> "$FILE_NAME"
echo "" >> "$FILE_NAME"
echo "## Comments" >> "$FILE_NAME"
echo "" >> "$FILE_NAME"
# 이슈의 코멘트 가져오기
COMMENTS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/${REPO_FULL_NAME}/issues/${ISSUE_NUMBER}/comments")
# 각 코멘트를 파일에 추가
echo "$COMMENTS" | jq -r '.[] | "### Comment by " + .user.login + " on " + .created_at + "\n\n" + .body + "\n"' >> "$FILE_NAME"
echo "Created file: $FILE_NAME"
- name: Commit and push changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add .
git commit -m "Add markdown file for closed issue #${ISSUE_NUMBER}"
git pull --rebase origin main
git push origin main