-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (49 loc) · 1.55 KB
/
today.yaml
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
name: "leetcode-question-today"
on:
schedule:
- cron: "0 1 * * *" # beijing 9am.
workflow_dispatch:
jobs:
today:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Checkout External Go Repo
uses: actions/checkout@v2
with:
repository: 'cloud-org/leetcode-question-today'
path: 'today'
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.21.3
- name: run cmd
working-directory: ./today
run: |
go mod tidy
go build -o ./main
./main > run.log 2>&1
- name: Parse log and create issue
uses: actions/github-script@v5
with:
script: |
const fs = require('fs');
const path = require('path');
const logPath = path.join(process.env.GITHUB_WORKSPACE, 'today','run.log');
const logContent = fs.readFileSync(logPath, 'utf8');
const lines = logContent.split('\n');
const titleIndex = lines.findIndex(line => line.startsWith('Title: '));
if (titleIndex !== -1) {
const title = lines[titleIndex];
const body = lines.slice(titleIndex + 1, titleIndex + 5).join('\n');
github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: title,
body: body,
labels: ['leetcode']
});
}