Skip to content

website: added logic to the pr_title_check.yaml to put error message as a comment #4051

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
**Checklist:**
- [ ] You have [signed off your commits](https://www.kubeflow.org/docs/about/contributing/#sign-off-your-commits)
- [ ] Ensure you follow best practices from our guide. [Contributing](https://github.com/kubeflow/website/blob/master/content/en/docs/about/contributing.md).
- [] You have included screenshots when changing the website style or adding a new page.
- [ ] You have included screenshots when changing the website style or adding a new page.


**Description of your changes:**
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/pr_title_check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,23 @@ jobs:
- name: Check PR Title Format
env:
PR_TITLE: ${{ github.event.pull_request.title }}
PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VALID_COMPONENTS="central-dashboard|katib|kserve|model-registry|notebooks|pipelines|spark-operator|trainer|gsoc|website|community"
if [[ ! "$PR_TITLE" =~ ^($VALID_COMPONENTS):\ .+ ]]; then
echo "❌ PR title does not follow the correct format: 'component_name: description'"
echo "Component value must be one of these central-dashboard|katib|kserve|model-registry|notebooks|pipelines|spark-operator|trainer|gsoc|website|community"
echo "Example: model-registry: Add model registry UI Installation instructions"

COMMENT_BODY="⚠️ **Invalid PR Title** ⚠️\n\nYour PR title \`$PR_TITLE\` does not match the required format: \`component_name: description\`.\n\n**Allowed components (case sensitive):** \`central-dashboard, katib, kserve, model-registry, notebooks, pipelines, spark-operator, trainer, gsoc, website, community\`\n\n✅ **Example:** \`model-registry: Add model registry UI Installation instructions\`\n\nPlease update your PR title accordingly by either using GITHUB GUI or by usinge \`/retitle component_name: description\` as stated above."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions else LGTM

Suggested change
COMMENT_BODY="⚠️ **Invalid PR Title** ⚠️\n\nYour PR title \`$PR_TITLE\` does not match the required format: \`component_name: description\`.\n\n**Allowed components (case sensitive):** \`central-dashboard, katib, kserve, model-registry, notebooks, pipelines, spark-operator, trainer, gsoc, website, community\`\n\n✅ **Example:** \`model-registry: Add model registry UI Installation instructions\`\n\nPlease update your PR title accordingly by either using GITHUB GUI or by usinge \`/retitle component_name: description\` as stated above."
COMMENT_BODY="⚠️ **Invalid PR Title** ⚠️\n\nYour PR title \`$PR_TITLE\` does not match the required format: \`component_name: description\`.\n\n**Allowed components (case sensitive):** \`central-dashboard, katib, kserve, model-registry, notebooks, pipelines, spark-operator, trainer, gsoc, website, community\`\n\n✅ **Example:** \`model-registry: Add model registry UI Installation instructions\`\n\nPlease update your PR title accordingly by either using GITHUB UI or by using comment command \`/retitle component_name: description\`."


# Post the comment to the PR using GitHub API
curl -s -H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
-X POST \
https://api.github.com/repos/${{ github.repository }}/issues/$PR_NUMBER/comments \
-d "{\"body\": \"$COMMENT_BODY\"}"
exit 1
fi
echo "✅ PR title format is correct."