Skip to content

Commit

Permalink
feat(pr-title): Add job summary and PR comments (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
chris3ware authored Apr 8, 2024
1 parent a45c46f commit 7f2488f
Showing 1 changed file with 39 additions and 3 deletions.
42 changes: 39 additions & 3 deletions .github/workflows/pr-title.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: Validate PR title

on:
pull_request_target:
types: [opened, edited, synchronize]
types: [opened, edited]
branches: [main]
workflow_call: {}

# Disable permissions for all available scopes
Expand All @@ -13,13 +14,48 @@ concurrency:
cancel-in-progress: true

jobs:
conventional-pr-title:
validate-pr-title:
permissions:
pull-requests: read
pull-requests: write
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Validate pull request title is conventional
id: lint-pr-title
uses: amannn/action-semantic-pull-request@47b15d52c5c30e94a17ec87eb8dd51ff5221fed9 # v5.3.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Add PR comment on failure
if: always() && (steps.lint-pr-title.outputs.error_message != null)
uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 # v2.9.0
with:
header: pr-title-lint-error
message: |
Pull request titles should follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like the proposed title needs to be adjusted.
Details:
```
${{ steps.lint-pr-title.outputs.error_message }}
```
- name: Delete PR comment on resolution
if: always() && (steps.lint-pr-title.outputs.error_message == null)
uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 # v2.9.0
with:
header: pr-title-lint-error
delete: true

- name: Summary
if: always() && (steps.lint-pr-title.outputs.error_message == null)
run: |
echo "# :white_check_mark: Pull Request title is valid" >> $GITHUB_STEP_SUMMARY
- name: Summary
if: always() && (steps.lint-pr-title.outputs.error_message != null)
run: |
echo "# :bangbang: Pull Request title is invalid" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "add something here depending on what the below looks like" >> $GITHUB_STEP_SUMMARY
echo "${{ steps.lint-pr-title.outputs.error_message }}" >> $GITHUB_STEP_SUMMARY

0 comments on commit 7f2488f

Please sign in to comment.