forked from BlueMoon-Labs/MOLOT-BlueMoon-Station
-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (63 loc) · 2.38 KB
/
tgs_merge_detector.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
name: TGS Test Merge Detector
on:
issue_comment:
types:
- created
jobs:
handle_test_merge:
runs-on: ubuntu-latest
steps:
- name: Check if comment is from the specified user
id: filter_comment
uses: actions/github-script@v6
with:
script: |
const comment = context.payload.comment;
const user = comment.user.login;
const body = comment.body;
const targetUser = process.env.TARGET_USER;
if (!targetUser) {
core.setFailed('TARGET_USER environment variable is not set.');
}
if (user !== targetUser) {
core.info(`Comment is not from the target user: ${user}`);
return "no_match";
}
if (body.includes('Test Merge Deployed')) {
return "deployed";
}
if (body.includes('Test Merge Removed')) {
return "removed";
}
core.info(`Comment does not contain target text.`);
return "no_match";
result-encoding: 'string'
env:
TARGET_USER: ${{ vars.TARGET_USER }}
- name: Skip if comment doesn't match criteria
if: steps.filter_comment.outputs.result == 'no_match'
run: echo "Comment did not meet criteria. Skipping."
- name: Add or remove label based on comment content
if: steps.filter_comment.outputs.result == 'deployed' || steps.filter_comment.outputs.result == 'removed'
uses: actions/github-script@v6
with:
script: |
const body = context.payload.comment.body;
const issueNumber = context.payload.issue.number;
if (body.includes('Test Merge Deployed')) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
labels: ['Test Merged']
});
core.info('Label "Test Merged" added.');
} else if (body.includes('Test Merge Removed')) {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
name: 'Test Merged'
});
core.info('Label "Test Merged" removed.');
}