Skip to content
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

T6851: update title and commit message checker and remove unused py script #55

Merged
merged 1 commit into from
Nov 4, 2024
Merged
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
42 changes: 30 additions & 12 deletions .github/workflows/check-pr-message.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

on:
workflow_call:

env:
GH_TOKEN: ${{ secrets.PAT }}

jobs:
check-pr-title:
Expand All @@ -21,23 +24,38 @@
repository: vyos/.github
path: reusable-actions

- name: Install the requests library
run: pip3 install requests

- name: Check the PR title
timeout-minutes: 2
id: check_pr_title
run: |
output=$(./reusable-actions/scripts/check-pr-title-and-commit-messages.py '${{ github.event.pull_request.url }}' 2>&1 || true)
if [ -n "$output" ]; then
echo "$output"
echo "error_message=${output//$'\n'/. }" >> $GITHUB_ENV
exit 1
source_pr_title=$(gh pr view "${{ github.event.pull_request.number }}" --repo "${{ github.repository }}" --json title -q .title)
if echo "$source_pr_title" | grep -Pq '^(([a-zA-Z0-9\-_.]+:\s)?)T\d+:\s+[^\s]+.*'; then
echo "PR title '$source_pr_title' is valid."
echo "error_message=No issues in PR Title / Commit Title" >> $GITHUB_ENV
else
#echo "error_message=" >> $GITHUB_ENV
echo "error_message=No issues in PR Title / Commit Title" >> $GITHUB_ENV
echo "PR title '$source_pr_title' does not match the required format!"
echo "error_message=PR title does not match the required format" >> $GITHUB_ENV
echo "Valid title example: T99999: make IPsec secure"
exit 1
fi
shell: bash

- name: Check commit messages
timeout-minutes: 2
run: |
# Fetch commit messages
commits=$(gh pr view "${{ github.event.pull_request.number }}" --repo "${{ github.repository }}" --json commits -q '.commits[].messageHeadline')
# Iterate over each commit message
echo "$commits" | while IFS= read -r commit_message; do
if echo "$commit_message" | grep -Pq '^(([a-zA-Z0-9\-_.]+:\s)?)T\d+:\s+[^\s]+.*'; then
echo "Commit message '$commit_message' is valid."
else
echo "Commit message '$commit_message' does not match the required format!"
echo "error_message=PR title does not match the required format" >> $GITHUB_ENV
echo "Valid commit message example: T99999: make IPsec secure"
exit 1
fi
done
echo "All commit messages are valid."
echo "error_message=No issues in PR Title / Commit Title" >> $GITHUB_ENV

- name: Add PR comment
if: always()
Expand Down
51 changes: 0 additions & 51 deletions scripts/check-pr-title-and-commit-messages.py

This file was deleted.