Rewrites the pull request validation

This commit is contained in:
Alicia Sykes 2022-08-01 22:44:18 +01:00 committed by GitHub
parent 184a49d6c8
commit e535c56fe6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 88 additions and 53 deletions

View File

@ -1,53 +0,0 @@
# Checks that PR title conform to contributing standards (or at least !== Update README.md)
name: ⛳ Lint PR
on:
pull_request:
types: [opened, edited, synchronize, reopened]
jobs:
check-title:
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: Check title regex
uses: morrisoncole/pr-lint-action@v1.6.1
with:
title-regex: "^(?!.*Update README.md).*"
on-failed-regex-fail-action: true
on-failed-regex-request-changes: true
on-failed-regex-create-review: true
on-failed-regex-comment: |
It looks like your title isn't very descriptive...
Please check the [contributing docs](https://github.com/Lissy93/awesome-privacy/blob/main/.github/CONTRIBUTING.md) before submitting a pull request.
on-succeeded-regex-dismiss-review-comment: ""
repo-token: "${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}"
- name: Check title prefix
uses: deepakputhraya/action-pr-title@v1.0.2
with:
allowed_prefixes: 'Adds,Add,Removes,Remove,Updates,Update,Fixes,Fix,Amends,[AUTO]' # title should start with the given prefix
disallowed_prefixes: 'Update README.md' # title should not start with the given prefix
prefix_case_sensitive: false # title prefix are case insensitive
min_length: 18 # Min length of the title
max_length: 60 # Max length of the title
github_token: ${{ secrets.BOT_GITHUB_TOKEN || github.token }}
- name: Check body includes tickboxes
uses: mtfoley/pr-compliance-action@main
with:
repo-token: ${{ secrets.BOT_GITHUB_TOKEN || github.token }}
ignore-authors: liss-bot
ignore-team-members: false
base-comment: ''
body-regex: "(\\[x]|\\[X]).(?!.*(\\[]|\\[ ])).*"
body-fail: true
body-auto-close: false
body-comment: |
You must complete the quality and transparency checklist.
protected-branch: ''
protected-branch-auto-close: false
protected-branch-comment: ''
title-check-enable: false
title-comment: ''
watch-files: ''
watch-files-comment: ''

88
.github/workflows/validate-pr.yml vendored Normal file
View File

@ -0,0 +1,88 @@
# Checks that PR title conform to contributing standards (or at least !== Update README.md)
name: ⛳ Validate PR
on:
pull_request:
types: [opened, edited, synchronize, reopened]
env:
BASE_MSG: >+
Thanks for contributing to Awesome-Privacy! Your pull request will be reviewed shortly.
In the meantime, please be sure that you have read, and complied with the guidelines outlined in the
[Contributing Docs](https://github.com/Lissy93/awesome-privacy/blob/main/.github/CONTRIBUTING.md).
jobs:
validate:
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: Validate Title is not Default
if: "contains(github.event.pull_request.title, 'Update README.md')"
uses: peter-evans/create-or-update-comment@v2
with:
token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body: |
Hi @${{ github.actor }},
Please update your pull request, to include a more descriptive title.
- name: Validate Checklist is Completed
if: >
contains(github.event.pull_request.body, '[ ]') ||
!(contains(github.event.pull_request.body, '[X]') || contains(github.event.pull_request.body, '[x]'))
uses: peter-evans/create-or-update-comment@v2
with:
token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body: |
Hello @${{ github.actor }} 👋
${{ env.BASE_MSG }}
⚠️ It looks like you've not complete the quality and transparency checklist.
- name: Validate Affiliation Section is Present
if: >
!contains(github.event.pull_request.body, 'Affiliation')
uses: peter-evans/create-or-update-comment@v2
with:
token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body: |
Hello @${{ github.actor }} 👋
${{ env.BASE_MSG }}
⚠️ You must indicate if you are affiliated with any software modified by this PR.
If not applicable, you may set this field to N/A.
- name: Validate Category
if: >
contains(github.event.pull_request.body, 'Addition / Amendment / Removal / Spelling or Grammar / Website Update / Misc') ||
!(
contains(github.event.pull_request.body, 'Addition') ||
contains(github.event.pull_request.body, 'Amendment') ||
contains(github.event.pull_request.body, 'Removal') ||
contains(github.event.pull_request.body, 'Spelling or Grammar') ||
contains(github.event.pull_request.body, 'Website Update') ||
contains(github.event.pull_request.body, 'Misc')
)
uses: peter-evans/create-or-update-comment@v2
with:
token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body: |
Hello @${{ github.actor }} 👋
${{ env.BASE_MSG }}
⚠️ You must specify a category
Either: `Addition`, `Amendment`, `Removal`, `Spelling or Grammar`, `Website Update`, or `Misc`.
- name: Validate Supporting Material is Present
if: >
!contains(github.event.pull_request.body, 'Supporting Material')
uses: peter-evans/create-or-update-comment@v2
with:
token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body: |
Hello @${{ github.actor }} 👋
${{ env.BASE_MSG }}
⚠️ If applicable, please ensure you've provided supporting material.