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-issue-close-actions
run-name: ${{ github.actor }} is issueing for ToDoList GitHub Actions
on:
workflow_dispatch:
schedule:
- cron: "00 13 * * *"
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: Close Issue
id: close_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 owner = "peer-42seoul";
const repo = "mangement-team-todo";
const response = await github.rest.issues.listForRepo({
owner,
repo,
state: 'open'
});
const listData = response.data;
for (var i = 0; i < listData.length; i++) {
if(listData[i].title === issueTitle)
{
await github.rest.issues.update({
owner,
repo,
issue_number: listData[i].number,
state: 'close'
})
}
};
# 깃헙 액션 로직
# 1. 8시 30분
# 2. 깃 액션으로 이슈 활성화
# 3. 깃 핀드 진행하기
# 4. 내용 집어넣기
# 5. 이메일 알람 보내기
# 1. 저녁 8시이면
# 2. 깃 액션으로 이슈 잠금
# 3. 깃 핀 해제