Skip to content

Commit 547b2f3

Browse files
🌱 (ci) - Fix the job to check the PR title and no longer use deprecated github action (#4095)
The kubebuilder-release-tools project is no longer really maintained. The image required for checks is deprecated due the infrastructure used to build and promote it be deprecated. Given the minimal nature of the check, it's unnecessary to maintain a GitHub Action for this purpose. Also, it broke 1 day ago. Note that we need to pass permissions via GitHub Token, which is not very safe. This is another reason why we need to proceed with these changes.
1 parent f3f07ae commit 547b2f3

File tree

2 files changed

+54
-11
lines changed

2 files changed

+54
-11
lines changed

.github/workflows/verify.yml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1-
name: PR Verifier
1+
name: "PR Title Verifier"
22

33
on:
4-
pull_request_target:
5-
types: [opened, edited, reopened]
6-
4+
pull_request:
5+
types: [opened, edited, synchronize, reopened]
76

87
jobs:
9-
108
verify:
11-
name: Verify PR contents
129
runs-on: ubuntu-latest
10+
1311
steps:
14-
- name: Verifier action
15-
id: verifier
16-
uses: kubernetes-sigs/kubebuilder-release-tools@v0.4.3
17-
with:
18-
github_token: ${{ secrets.GITHUB_TOKEN }}
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Get PR title
16+
id: get_title
17+
run: echo "title=${{ github.event.pull_request.title }}" >> $GITHUB_ENV
18+
19+
- name: Run PR Title Checker
20+
id: check_title
21+
run: |
22+
./hack/ci/pr_title_checker.sh "${{ env.title }}"

hack/ci/pr_title_checker.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
# Copyright 2024 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# Define regex patterns
18+
WIP_REGEX="^\W?WIP\W"
19+
TAG_REGEX="^\[[[:alnum:]\._-]*\]"
20+
PR_TITLE="$1"
21+
22+
# Trim WIP and tags from title
23+
trimmed_title=$(echo "$PR_TITLE" | sed -E "s/$WIP_REGEX//" | sed -E "s/$TAG_REGEX//" | xargs)
24+
25+
# Check PR type prefix
26+
if [[ "$trimmed_title" =~ ^⚠ ]] || [[ "$trimmed_title" =~ ^✨ ]] || [[ "$trimmed_title" =~ ^🐛 ]] || [[ "$trimmed_title" =~ ^📖 ]] || [[ "$trimmed_title" =~ ^🚀 ]] || [[ "$trimmed_title" =~ ^🌱 ]]; then
27+
echo "PR title is valid: $trimmed_title"
28+
exit 0
29+
else
30+
echo "Error: No matching PR type indicator found in title."
31+
echo "You need to have one of these as the prefix of your PR title:"
32+
echo "- Breaking change: ⚠ (:warning:)"
33+
echo "- Non-breaking feature: ✨ (:sparkles:)"
34+
echo "- Patch fix: 🐛 (:bug:)"
35+
echo "- Docs: 📖 (:book:)"
36+
echo "- Release: 🚀 (:rocket:)"
37+
echo "- Infra/Tests/Other: 🌱 (:seedling:)"
38+
exit 1
39+
fi

0 commit comments

Comments
 (0)