forked from GreenBlitz/GB-Robot-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (54 loc) · 2.38 KB
/
addTestsLabels.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
name: Add Tests Labels
on:
pull_request:
types:
- opened
- reopened
- synchronize
jobs:
add-tests-labels:
runs-on: ubuntu-latest
env:
ROBOT_TESTING: "needs-robot-testing"
NO_ROBOT_TESTING: "no-need-of-robot-testing"
SIMULATION_TESTING: "needs-simulation-testing"
NO_SIMULATION_TESTING: "no-need-of-simulation-testing"
PASSED_ALL_TESTS: "passed-all-tests"
stop: 'false'
steps:
- name: get existing labels
run: |
existingLabels=$(jq -r '.pull_request.labels[].name' $GITHUB_EVENT_PATH | tr '\n' ' ')
echo "existing-labels=${existingLabels}" >>$GITHUB_ENV
echo "Existing labels: $existingLabels"
- name: Open Behavior
if: ${{ github.event.action == 'opened' && contains(env.existing-labels, env.PASSED_ALL_TESTS)}}
run: |
echo "stop=true" >>$GITHUB_ENV
- name: add needs robot test
if: ${{ env.stop == 'false'
&& !contains(env.existing-labels, env.ROBOT_TESTING)
&& !contains(env.existing-labels, env.NO_ROBOT_TESTING)}}
run: |
curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.number }}/labels \
-d "{\"labels\":[\"${ROBOT_TESTING}\"]}"
- name: add needs simulation test
if: ${{env.stop == 'false'
&& !contains(env.existing-labels, env.SIMULATION_TESTING)
&& !contains(env.existing-labels, env.NO_SIMULATION_TESTING)}}
run: |
curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.number }}/labels \
-d "{\"labels\":[\"${SIMULATION_TESTING}\"]}"
- name: remove passed all tests
if: ${{env.stop == 'false' && contains(env.existing-labels, env.PASSED_ALL_TESTS)}}
run: |
curl -X DELETE \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.number }}/labels/${PASSED_ALL_TESTS}"