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

feat(pr-title): Add job summary and PR comments #91

Merged
merged 6 commits into from
Apr 8, 2024
Merged
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: 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
Loading