-
Notifications
You must be signed in to change notification settings - Fork 441
79 lines (73 loc) · 2.98 KB
/
gcr.io_mirror.yml
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
name: gcr.io_mirror
on:
schedule:
- cron: '0 16 * * *'
issues:
types: [opened, edited]
label:
types: [created]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 检出代码
uses: actions/checkout@v3
- name: 设置 golang 环境
uses: actions/setup-go@v3
with:
go-version: 1.18
check-latest: true
cache: true
- name: 运行 go 代码
run: go run main.go --github.token=${{ secrets.GITHUB_TOKEN }} --github.user=${{ github.repository_owner }} --github.repo=${{ github.event.repository.name }} --docker.registry=${{ secrets.DOCKER_REGISTRY }} --docker.namespace=${{ secrets.DOCKER_NAMESPACE }} --docker.user=${{ secrets.DOCKER_USER }} --docker.secret=${{ secrets.DOCKER_PASSWORD }} --github.run_id=${{ github.run_id }}
auto_close_issues:
runs-on: ubuntu-latest
steps:
- name: check issues
id: check_issues
uses: actions/github-script@v3.1.0
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const openIssues = await github.issues.listForRepo({
owner: '${{ github.repository_owner }}',
repo: '${{ github.event.repository.name }}',
state: 'open',
per_page: 100,
sort: "created",
direction: "desc",
})
if (!Array.isArray(openIssues["data"]) || !openIssues["data"].length) {
core.setOutput('SUCCESS', true)
return
}
let validLabels=false
for(let issues of openIssues['data']){
for(let labels of issues["labels"]){
if(labels["name"]=="porter" || labels["name"]=="question"){
validLabels=true
}
}
if(validLabels){
continue
}
await github.issues.createComment({
owner: '${{ github.repository_owner }}',
repo: '${{ github.event.repository.name }}',
issue_number: issues["number"],
body: "@"+issues["user"]["login"]+" 不是说了嘛,通过模板创建 issues,请通过[此模板](https://github.com/anjia0532/gcr.io_mirror/issues/new?assignees=&labels=porter&template=porter.md&title=%5BPORTER%5D)重新创建,此 issues 将自动关闭"
});
await github.issues.addLabels({
owner: '${{ github.repository_owner }}',
repo: '${{ github.event.repository.name }}',
issue_number: issues["number"],
labels: ["rude"]
});
await github.issues.update({
owner: '${{ github.repository_owner }}',
repo: '${{ github.event.repository.name }}',
issue_number: issues["number"],
state: 'closed'
})
}