Skip to content

Create Daily Scrum Template Every Day #59

Create Daily Scrum Template Every Day

Create Daily Scrum Template Every Day #59

name: Create Daily Scrum Template Every Day
on:
schedule:
# 매일 오전 7시(KST)에 실행 (UTC 10시). github action cron은 정각이 보장되지 않아 여유 시간을 주어야 함
- cron: '0 22 * * 0-5'
workflow_dispatch:
jobs:
create-md-file:
runs-on: ubuntu-latest
steps:
- name: Send Notification to Discord
id: send_notification
run: |
DATE=$(LC_TIME=ko_KR.UTF-8 date +'%y.%m.%d(%a)' -d '9 hours')
DAY=$(date -u -d '9 hours' +'%a')
# 영어 요일을 한글로 변환
case $DAY in
Mon) DAY_KOR="월" ;;
Tue) DAY_KOR="화" ;;
Wed) DAY_KOR="수" ;;
Thu) DAY_KOR="목" ;;
Fri) DAY_KOR="금" ;;
Sat) DAY_KOR="토" ;;
Sun) DAY_KOR="일" ;;
esac
DATE=$(echo "$DATE" | sed "s/($DAY)/($DAY_KOR)/")
DISCORD_WEBHOOK_URL="${{ secrets.DISCORD_DAILY_WEBHOOK_URL }}?wait=true"
MESSAGE="${DATE} 데일리 스크럼"
PAYLOAD=$(echo "{\"content\": \"${MESSAGE}\"}")
RESPONSE=$(curl -X POST -H "Content-Type: application/json" \
-d "$PAYLOAD" \
$DISCORD_WEBHOOK_URL)
MESSAGE_ID=$(echo $RESPONSE | jq -r '.id')
echo "message_id=$MESSAGE_ID" >> $GITHUB_OUTPUT
- name: Create Thread based on Message
id: create_thread
env:
DISCORD_BOT_TOKEN: ${{ secrets.DISCORD_DAILY_BOT_TOKEN }}
DISCORD_CHANNEL_ID: "1296729268813828148"
run: |
MESSAGE_ID="${{ steps.send_notification.outputs.message_id }}"
THREAD_NAME="${DATE} 데일리 스크럼 스레드"
RESPONSE=$(curl -X POST "https://discord.com/api/channels/$DISCORD_CHANNEL_ID/messages/$MESSAGE_ID/threads" \
-H "Authorization: Bot $DISCORD_BOT_TOKEN" \
-H "User-Agent: DiscordBot (https://github.com/animal-squad, 1.0.0)" \
-H "Content-Type: application/json" \
-d "{\"name\": \"$THREAD_NAME\", \"auto_archive_duration\": 1440}")
echo "RESPONSE: $RESPONSE"
THREAD_ID=$(echo $RESPONSE | jq -r '.id')
echo "THREAD_ID: $THREAD_ID"
echo "thread_id=${THREAD_ID}" >> $GITHUB_OUTPUT
- name: Send Scrum Message to Thread
if: steps.create_thread.outputs.thread_id != ''
env:
DISCORD_BOT_TOKEN: ${{ secrets.DISCORD_DAILY_BOT_TOKEN }}
THREAD_ID: ${{ steps.create_thread.outputs.thread_id }}
run: |
# 텍스트 내용 정의
SCRUM_MESSAGE="### [스크럼 제목] (선택)\n\n### 어제 한 일 :pencil:\n- :white_check_mark: 한 일 1\n- :white_check_mark: 한 일 2\n- :x: 트러블\n\n### 부가 설명 :pencil2:\n[사진]\n[영상]\n[링크]\n\n### 오늘 할 일 :clock2:\n- :white_check_mark: 할 일 1\n- :white_check_mark: 할 일 2\n\n### 추가 제안 사항 :raised_hand:\n- 제안 사항 1"
# 스레드에 메시지 전송
curl -X POST "https://discord.com/api/channels/$THREAD_ID/messages" \
-H "Authorization: Bot $DISCORD_BOT_TOKEN" \
-H "User-Agent: DiscordBot (https://github.com/animal-squad, 1.0.0)" \
-H "Content-Type: application/json" \
-d "{\"content\": \"$SCRUM_MESSAGE\"}"