-
Notifications
You must be signed in to change notification settings - Fork 1.8k
43 lines (39 loc) · 1.69 KB
/
sign_check.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
name: sign
on:
pull_request:
paths:
- 'signed/*'
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/[email protected]
with:
github-token: ${{github.token}}
script: |
try {
const { data: files } = await github.request(`${context.payload.pull_request.url}/files`)
const signs = files.filter(f => f.status === 'added')
if (signs.length > 0) {
const valid = s => s.split('|').length == 2
for (var i=0; i<signs.length; i++) {
const { data: content } = await github.request(signs[i].raw_url)
content.trim().split('\n').forEach(s => {
if (!valid(s))
throw new Error('Too many vertical bars')
})
//const re = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i
//const [ dir, file ] = signs[i].filename.split('/')
//if (!re.test(file))
// throw new Error('Incorrect file name. Please use [UUID](https://www.uuidgenerator.net/) as name of signature file')
}
//await github.issues.createComment({...context.issue, body: 'Thanks for your signature! 🎉'})
//await github.issues.update({...context.issue, labels: ['correct']})
// await github.pulls.merge({...context.issue})
}
} catch (error) {
await github.issues.createComment({...context.issue, body: error.message})
await github.issues.update({...context.issue, labels: ['incorrect']})
throw 'build failed'
}