-
Notifications
You must be signed in to change notification settings - Fork 40
83 lines (69 loc) · 2.6 KB
/
replyIssueCreate.yml
File metadata and controls
83 lines (69 loc) · 2.6 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: ReplyIssueCreate
on:
issues:
types: [opened]
jobs:
permission:
name: permission check
runs-on: ubuntu-latest
if: ${{ github.actor != 'github-actions[bot]' && !startsWith(github.event.issue.title, '[Issue]') }}
steps:
- name: check permission
run: |
echo ${{ github.actor }}
echo permission pass
build:
runs-on: ubuntu-latest
needs: permission
steps:
- uses: actions/checkout@v5
- name: Set up Python 3.13
uses: actions/setup-python@v6
with:
python-version: 3.13
- name: Generate github hosts
run: |
python socket_query.py
- uses: actions/github-script@v8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
let reg = /\[Host\]\d{4}-\d{2}-\d{2}/
if (!reg.test("${{ github.event.issue.title }}")) {
const d = new Date();
const localTime = d.getTime();
const localOffset = d.getTimezoneOffset() * 60000; //getTimezoneOffset()返回是以分钟为单位,需要转化成ms
const utc = localTime + localOffset;
const offset = 8; //东8区
const beijing = utc + (3600000 * offset);
const nd = new Date(beijing);
let year = "" + nd.getFullYear();
let month = nd.getMonth() + 1;
month = month >= 10 ? "" + month : "0" + month;
let day = nd.getDate();
day = day >= 10 ? "" + day : "0" + day;
const title = `[Host]${year}-${month}-${day}`;
console.log("title is: " + title);
github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
title: title,
});
}
let fs = require("fs");
fs.readFile("hosts.txt", 'utf-8', (err, data) => {
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: data
}).then((res) => {
github.rest.issues.lock({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
lock_reason: "off-topic",
});
});
});