@@ -2,14 +2,30 @@ name: CRD Validation
22
33on :
44 pull_request :
5- types : [opened, edited, synchronize, reopened]
5+ types : [opened, edited, synchronize, reopened, labeled, unlabeled]
6+ issue_comment :
7+ types : [created]
68
79permissions :
810 contents : read
11+ pull-requests : write
912
1013jobs :
14+ ack-breaking-changes :
15+ name : Ack Breaking Changes Labeler
16+ if : github.event.issue.pull_request && contains(github.event.comment.body, '/ack-breaking-changes')
17+ runs-on : ubuntu-latest
18+ steps :
19+ - name : Add Label
20+ env :
21+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
22+ run : |
23+ gh pr edit ${{ github.event.issue.number }} --add-label "ack-breaking-changes"
24+ echo "✅ Added 'ack-breaking-changes' label based on comment."
25+
1126 crd-validation :
1227 name : CRD Validation Check
28+ if : github.event_name == 'pull_request'
1329 runs-on : ubuntu-latest
1430 steps :
1531 - name : Checkout code
2844 run : |
2945 go install sigs.k8s.io/crdify@latest
3046
47+ - name : Reset Validation Approval
48+ if : github.event.action == 'synchronize' && contains(github.event.pull_request.labels.*.name, 'ack-breaking-changes')
49+ env :
50+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
51+ run : |
52+ gh pr edit ${{ github.event.pull_request.number }} --remove-label "ack-breaking-changes"
53+ echo "⚠️ Removed 'ack-breaking-changes' label due to new changes. Re-approval required."
54+
3155 - name : Run CRD Validation Check
56+ env :
57+ ALLOW_BREAKING : ${{ contains(github.event.pull_request.labels.*.name, 'ack-breaking-changes') && github.event.action != 'synchronize' }}
3258 run : |
3359 git fetch origin ${{ github.base_ref }}:upstream_base
3460 BASE_SHA=$(git rev-parse upstream_base)
4470 done
4571
4672 if [ "$FAILED" -gt 0 ]; then
47- echo "::error::Validation failed! Found $FAILED incompatible CRD change(s)."
48- exit 1
73+ if [[ "$ALLOW_BREAKING" == "true" ]]; then
74+ echo "⚠️ Validation failed with $FAILED incompatible change(s), but allowed via 'ack-breaking-changes' label."
75+ exit 0
76+ else
77+ echo "❌ error: Validation failed! Found $FAILED incompatible CRD change(s)."
78+ echo "⚠️ notice: To allow these changes, a reviewer must add the 'ack-breaking-changes' label to the PR or comment '/ack-breaking-changes'."
79+ exit 1
80+ fi
4981 fi
5082
5183 echo "All CRDs are compatible."
0 commit comments