Skip to content

Paul2021-R is issueing for ToDoList GitHub Actions #55

Paul2021-R is issueing for ToDoList GitHub Actions

Paul2021-R is issueing for ToDoList GitHub Actions #55

name: auto-git-issue-actions
run-name: ${{ github.actor }} is issueing for ToDoList GitHub Actions
on:
workflow_dispatch:
schedule:
- cron: "00 23 * * *"
jobs:
open-issue:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check Current Time
id: check-time
run: |
date
echo "::set-output name=hour::$(date -d '+9 hours' +'%H')"
- name: Time Testing
id: time_testing
uses: actions/github-script@v6
with:
github-token: ${{secrets.TOKEN}}
script: |
const currentDate = new Date();
console.log("현재 시각 : " + currentDate.getHours());
const kTime = currentDate.getHours() + 9
console.log("현재 시각 + 9 : " + kTime);
const korOffset = 9 * 60;
const currentKOR = new Date(currentDate.getTime() + korOffset * 60000);
const dayOfWeek = currentKOR.getDay();
if (dayOfWeek === 0) {
console.log("일요일입니다. 종료 합니다.");
}
else if (dayOfWeek === 6) {
console.log("토요일입니다. 종료 합니다.");
}
else {
console.log("현재는 평일입니다!");
}
- name: Create Issue
id: create_issue
uses: actions/github-script@v6
with:
github-token: ${{secrets.TOKEN}}
script: |
const currentDate = new Date();
const korOffset = 9 * 60;
const currentKOR = new Date(currentDate.getTime() + korOffset * 60000);
const dayOfWeek = currentKOR.getDay();
if (dayOfWeek === 0) {
console.log("일요일입니다. 종료 합니다.");
return;
}
else if (dayOfWeek === 6) {
console.log("토요일입니다. 종료 합니다.");
return ;
}
else
console.log("현재는 평일입니다!" + '\n' + "ToDo List issue 를 발행합니다.");
const date = currentKOR.toISOString().split('T')[0];
const issueTitle = `${date}-TODO`;
const issueBody1 = `# 투두리스트 작성하는 법\n`;
const issueBody2 = `### (1) 아래 코멘트로 오늘 할 일 적기.\n`;
const issueBody3 = `### (2) 저녁 8시 전까지 무슨 일을 하셨는지 체킹하기.\n`;
const issueBody4 = `### 참고사항 본인의 작업 코드에 해당하는 이슈 링크 첨부 권장 (그 사람이 전체적인 작업 현황을 쉽게 볼 수 있으면 좋겠다는 의견)`;
const issueBody5 = `
---
### ToDo List 작성 예시 : 마크다운 표 작성 방식 참고할 것! 귀찮으면 긁어서 사용하시면 됩니다~
\`\`\`
| **시작 시간** | **종료 시간** | **제목** | **내용** |
|:---:|:---:|:---|:---|
|09:00|13:00|제목 작성|내용작성 |
// 요걸 잘 활용해서 내용을 적으면 아래처럼 표시가 됩니다 ~
\`\`\`
| **시작 시간** | **종료 시간** | **제목** | **내용** |
|:---:|:---:|:---|:---|
|09:00|13:00|제목 작성|내용작성 |`;
const issueBody = issueBody1 + issueBody2 + issueBody3 + issueBody4 + issueBody5;
const owner = "peer-42seoul";
const repo = "management-team-todo";
const newIssue = await github.rest.issues.create({
owner,
repo,
title: issueTitle,
body: issueBody
});