2023-09-02 23:11:21 +02:00
name : Check Pull Requests
2023-09-01 22:56:40 -04:00
on :
2023-09-02 23:11:21 +02:00
pull_request_target :
2023-09-01 22:56:40 -04:00
types :
- opened
- edited
2023-09-02 23:11:21 +02:00
- synchronize
2023-09-10 05:19:03 -04:00
- labeled
- unlabeled
2023-09-02 23:11:21 +02:00
merge_group :
permissions :
2023-09-10 03:29:06 -04:00
pull-requests : write
2023-09-01 22:56:40 -04:00
jobs :
check-title :
runs-on : ubuntu-latest
steps :
2023-09-02 23:11:21 +02:00
- name : Check PR title
if : github.event_name == 'pull_request_target'
uses : amannn/action-semantic-pull-request@v5
2023-09-09 21:06:31 -04:00
id : check_pr_title
2023-09-02 23:11:21 +02:00
env :
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
2023-09-09 21:06:31 -04:00
# Add comment indicating we require pull request titles to follow conventional commits specification
- uses : marocchino/sticky-pull-request-comment@v2
if : always() && (steps.check_pr_title.outputs.error_message != null)
with :
header : pr-title-lint-error
message : |
2023-09-10 03:29:06 -04:00
Thank you for opening this pull request!
2023-09-09 21:06:31 -04:00
We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like your proposed title needs to be adjusted.
Details :
> ${{ steps.check_pr_title.outputs.error_message }}
# Delete a previous comment when the issue has been resolved
- if : ${{ steps.check_pr_title.outputs.error_message == null }}
uses : marocchino/sticky-pull-request-comment@v2
with :
header : pr-title-lint-error
delete : true
2024-01-08 13:30:06 +01:00
check-signed :
runs-on : ubuntu-latest
permissions :
contents : read
2024-01-08 16:26:15 +01:00
pull-requests : write
2024-01-08 13:30:06 +01:00
steps :
# Check commit signature and add comment if needed
- name : Check signed commits in PR
uses : 1Password/check-signed-commits-action@v1
with :
comment : |
Thank you for opening this pull request!
We require commits to be signed and it looks like this PR contains unsigned commits.
Get help in the [CONTRIBUTING.md](https://github.com/ratatui-org/ratatui/blob/main/CONTRIBUTING.md#sign-your-commits)
or on [Github doc](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits).
2023-09-09 21:06:31 -04:00
check-breaking-change-label :
runs-on : ubuntu-latest
2023-12-09 06:49:26 -08:00
env :
# use an environment variable to pass untrusted input to the script
# see https://securitylab.github.com/research/github-actions-untrusted-input/
PR_TITLE : ${{ github.event.pull_request.title }}
2023-09-09 21:06:31 -04:00
steps :
- name : Check breaking change label
2023-09-10 03:29:06 -04:00
id : check_breaking_change
2023-09-09 21:06:31 -04:00
run : |
2023-09-10 03:29:06 -04:00
pattern='^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(\w+\))?!:'
2023-09-10 04:14:51 -04:00
# Check if pattern matches
2023-12-09 06:49:26 -08:00
if echo "${PR_TITLE}" | grep -qE "$pattern"; then
2023-09-10 03:29:06 -04:00
echo "breaking_change=true" >> $GITHUB_OUTPUT
2023-09-09 21:06:31 -04:00
else
2023-09-10 03:29:06 -04:00
echo "breaking_change=false" >> $GITHUB_OUTPUT
2023-09-09 21:06:31 -04:00
fi
- name : Add label
2023-09-10 03:29:06 -04:00
if : steps.check_breaking_change.outputs.breaking_change == 'true'
2023-11-20 14:43:06 -08:00
uses : actions/github-script@v7
2023-09-09 21:06:31 -04:00
with :
2023-09-10 03:29:06 -04:00
github-token : ${{ secrets.GITHUB_TOKEN }}
2023-09-09 21:06:31 -04:00
script : |
2023-09-10 03:29:06 -04:00
github.rest.issues.addLabels({
2023-09-09 21:06:31 -04:00
issue_number : context.issue.number,
owner : context.repo.owner,
repo : context.repo.repo,
labels : [ 'breaking change' ]
})
2023-09-10 04:14:51 -04:00
do-not-merge :
if : ${{ contains(github.event.*.labels.*.name, 'do not merge') }}
name : Prevent Merging
runs-on : ubuntu-latest
steps :
- name : Check for label
run : |
echo "Pull request is labeled as 'do not merge'"
echo "This workflow fails so that the pull request cannot be merged"
exit 1