11
22on :
33 pull_request :
4- # types: [opened, synchronize, reopened, labeled, unlabeled]
54 types : [labeled]
6- pull_request_target :
7- types : [labeled]
8-
95
106permissions :
11- issues : write # Allows the token to modify issues (needed for label management)
12- pull-requests : write # Allows the token to interact with pull requests
7+ pull-requests : write
138
149concurrency :
1510 group : ${{ github.workflow }}-${{ github.ref }}
@@ -33,21 +28,39 @@ jobs:
3328 echo "Running validation because 'full validation' label was added"
3429 # Add your validation logic here (e.g., linting, testing)
3530
36- remove-label :
37- needs : validate
38- if : always() # Ensures this runs even if validation fails
39- runs-on : ubuntu-latest
31+ sleep 10
32+ exit 0
4033
41- steps :
42- - name : Remove 'needs-validation' label
34+ - name : Remove label
35+ if : always()
4336 run : |
4437 PR_NUMBER=${{ github.event.pull_request.number }}
4538 REPO=${{ github.repository }}
4639 LABEL="full validation"
40+
41+ # URL-encodes the label by replacing special characters with their percent-encoded equivalents.
4742 ENCODED_LABEL=$(printf "%s" "$LABEL" | sed -e 's/ /%20/g' -e 's/:/%3A/g' -e 's/\//%2F/g' -e 's/?/%3F/g' -e 's/&/%26/g' -e 's/=/%3D/g')
4843
49- echo $ENCODED_LABEL
5044 echo "https://api.github.com/repos/$REPO/issues/$PR_NUMBER/labels/$ENCODED_LABEL"
5145 curl -X DELETE -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
5246 -H "Accept: application/vnd.github.v3+json" \
53- "https://api.github.com/repos/$REPO/issues/$PR_NUMBER/labels/${ENCODED_LABEL}"
47+ "https://api.github.com/repos/$REPO/issues/$PR_NUMBER/labels/${ENCODED_LABEL}"
48+
49+ # remove-label:
50+ # needs: validate
51+ # if: always() # Ensures this runs even if validation fails
52+ # runs-on: ubuntu-latest
53+
54+ # steps:
55+ # - name: Remove 'needs-validation' label
56+ # run: |
57+ # PR_NUMBER=${{ github.event.pull_request.number }}
58+ # REPO=${{ github.repository }}
59+ # LABEL="full validation"
60+ # ENCODED_LABEL=$(printf "%s" "$LABEL" | sed -e 's/ /%20/g' -e 's/:/%3A/g' -e 's/\//%2F/g' -e 's/?/%3F/g' -e 's/&/%26/g' -e 's/=/%3D/g')
61+
62+ # echo $ENCODED_LABEL
63+ # echo "https://api.github.com/repos/$REPO/issues/$PR_NUMBER/labels/$ENCODED_LABEL"
64+ # curl -X DELETE -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
65+ # -H "Accept: application/vnd.github.v3+json" \
66+ # "https://api.github.com/repos/$REPO/issues/$PR_NUMBER/labels/${ENCODED_LABEL}"
0 commit comments