-
Notifications
You must be signed in to change notification settings - Fork 7
82 lines (77 loc) · 2.62 KB
/
reviewapp.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
80
81
82
name: grant 'reviewapps' label if there are any changes in PR's source code.
on: pull_request
jobs:
labeling:
runs-on: ubuntu-latest # windows-latest | macos-latest
name: grant 'reviewapps' label
if: ${{ ! startsWith(github.head_ref, 'renovate/') }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: '3.10'
architecture: 'x64'
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v37
with:
use_fork_point: true
- name: List all changed files
id: check-paths-ignore
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
FLAG=$(cat << '_EOF_' | python
import os
import sys
import pathlib
paths_ignore = [
'.github/**/*.yml',
'**.md',
]
all_changed_files = os.getenv("ALL_CHANGED_FILES").split()
for filename in all_changed_files:
if not any(list(map(lambda pattern: pathlib.PurePath(filename).match(pattern), paths_ignore))):
print("false")
sys.exit()
print("true")
_EOF_
)
echo "::set-output name=FLAG::${FLAG}"
- name: Labeling 'reviewapps' to PR
uses: actions/github-script@v6
id: set-result
if: ${{ steps.check-paths-ignore.outputs.FLAG == 'false' }}
with:
result-encoding: string
script: |
const message = `
Review app
* https://dreamkast-dk-%d.dev.cloudnativedays.jp
`;
const targetLabel = 'reviewapps';
issue = await github.rest.issues.get({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
flag = false;
issue.data.labels.filter(label => {
if (label.name == targetLabel) { flag = true; };
});
if (!flag) {
github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: [targetLabel]
});
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: message.replace("%d", context.issue.number),
});
}