Skip to content

LT-22723: Agent skills for filing Jira issues and writing PR bodies #3169

LT-22723: Agent skills for filing Jira issues and writing PR bodies

LT-22723: Agent skills for filing Jira issues and writing PR bodies #3169

Workflow file for this run

name: Commit messages check
on:
pull_request:
workflow_call:
permissions:
contents: read
# pull-requests: write lets the sticky-comment step post and clear the
# commit-message feedback comment on the PR.
pull-requests: write
jobs:
gitlint:
name: Check commit messages
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Install dependencies
shell: pwsh
run: pip install --upgrade gitlint
- name: Lint git commit messages
shell: pwsh
# run the linter and tee the output to a file, this will make the check fail but allow us to use the results in summary
run: |
# Pre-create the file: Tee-Object never creates (or even truncates) its target when the
# piped command emits zero objects, which is exactly what a clean gitlint run does.
New-Item -ItemType File -Path check_results.log -Force | Out-Null
gitlint --ignore body-is-missing --commits "origin/$env:GITHUB_BASE_REF.." 2>&1 | Tee-Object -FilePath check_results.log
exit $LASTEXITCODE
- name: Propegate Error Summary
if: always()
shell: pwsh
# put the output of the commit message linting into the summary for the job and in an environment variable
run: |
# Change the commit part of the log into a markdown link to the commit
$commitsUrl = "https://github.com/${{ github.repository_owner }}/${{ github.event.repository.name }}/commit/"
$replacement = '[commit $1](' + $commitsUrl + '$1)'
$log = (Get-Content check_results.log -Raw) -replace 'Commit ([0-9a-f]{7,40})', $replacement
Set-Content -Path check_results.log -Value $log -NoNewline
# Put the results into the job summary
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value $log
# Put the results into a multi-line environment variable to use in the next step.
# $log echoes the PR's own commit messages, so a static heredoc marker could be
# reproduced in a commit to close the block early and inject arbitrary variables.
# A random per-run delimiter cannot be known in advance, so the content is inert.
$delimiter = "LINT_EOF_$([guid]::NewGuid().ToString('N'))"
Add-Content -Path $env:GITHUB_ENV -Value "check_results<<$delimiter"
Add-Content -Path $env:GITHUB_ENV -Value $log
Add-Content -Path $env:GITHUB_ENV -Value $delimiter
# add a comment on the PR if the commit message linting failed
- name: Comment on PR
if: failure()
uses: marocchino/sticky-pull-request-comment@v3
with:
header: Commit Comment
message: |
⚠️ Commit Message Format Issues ⚠️
${{ env.check_results }}
- name: Clear PR Comment
if: success()
uses: marocchino/sticky-pull-request-comment@v3
with:
header: Commit Comment
hide: true
hide_classify: "RESOLVED"