1+
2+ on :
3+ pull_request :
4+ types : [labeled]
5+
6+ permissions :
7+ pull-requests : write
8+
9+ concurrency :
10+ group : ${{ github.workflow }}-${{ github.ref }}
11+ cancel-in-progress : true
12+
13+
14+ jobs :
15+ validate :
16+ name : ' Validate Changed Packages'
17+ if : contains(github.event.pull_request.labels.*.name, 'full validation')
18+ runs-on : ubuntu-latest
19+
20+ steps :
21+ - name : Checkout code
22+ uses : actions/checkout@v4
23+ with :
24+ fetch-depth : 0
25+
26+ - name : Run Validation Script
27+ run : |
28+ echo "Running validation because 'full validation' label was added"
29+ # Add your validation logic here (e.g., linting, testing)
30+
31+ sleep 30
32+ exit 0
33+
34+ - name : Remove label
35+ if : always()
36+ run : |
37+ PR_NUMBER=${{ github.event.pull_request.number }}
38+ REPO=${{ github.repository }}
39+ LABEL="full validation"
40+
41+ # URL-encodes the label by replacing special characters with their percent-encoded equivalents.
42+ 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')
43+
44+ echo "https://api.github.com/repos/$REPO/issues/$PR_NUMBER/labels/$ENCODED_LABEL"
45+ curl -X DELETE -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
46+ -H "Accept: application/vnd.github.v3+json" \
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