Skip to content

Stuff improved

Stuff improved #479

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}"