.github/workflows/validate-pr.yml

90 lines · 3833 bytes

 1# Checks that PR title conform to contributing standards (or at least !== Update README.md)
 2name: ⛳ Validate PR
 3on:
 4  pull_request:
 5    types: [opened, edited, synchronize, reopened]
 6
 7permissions:
 8  pull-requests: write
 9
10env:
11  BASE_MSG: >+
12    Thanks for contributing to Awesome-Privacy! Your pull request will be reviewed shortly.
13    
14    In the meantime, please be sure that you have read, and complied with the guidelines outlined in the
15    [Contributing Docs](https://github.com/Lissy93/awesome-privacy/blob/main/.github/CONTRIBUTING.md).
16
17jobs:
18  validate:
19    runs-on: ubuntu-latest
20    steps:
21    - name: Validate Title is not Default
22      if: "contains(github.event.pull_request.title, 'Update README.md')"
23      uses: peter-evans/create-or-update-comment@v2
24      with:
25        token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
26        issue-number: ${{ github.event.pull_request.number }}
27        body: |
28          Hi @${{ github.actor }},
29          Please update your pull request, to include a more descriptive title.
30        
31    - name: Validate Checklist is Completed
32      if: >
33        contains(github.event.pull_request.body, '[ ]') ||
34        !(contains(github.event.pull_request.body, '[X]') || contains(github.event.pull_request.body, '[x]'))
35      uses: peter-evans/create-or-update-comment@v2
36      with:
37        token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
38        issue-number: ${{ github.event.pull_request.number }}
39        body: |
40          Hello @${{ github.actor }} 👋
41          ${{ env.BASE_MSG }}
42          ⚠️ It looks like you've not complete the quality and transparency checklist.
43        
44    - name: Validate Affiliation Section is Present
45      if: >
46        !contains(github.event.pull_request.body, 'Affiliation')
47      uses: peter-evans/create-or-update-comment@v2
48      with:
49        token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
50        issue-number: ${{ github.event.pull_request.number }}
51        body: |
52          Hello @${{ github.actor }} 👋
53          ${{ env.BASE_MSG }}
54          ⚠️ You must indicate if you are affiliated with any software modified by this PR.
55          If not applicable, you may set this field to N/A.       
56             
57    - name: Validate Category
58      if: >
59        contains(github.event.pull_request.body, 'Addition / Amendment / Removal / Spelling or Grammar / Website Update / Misc') ||
60        !(
61          contains(github.event.pull_request.body, 'Addition') ||
62          contains(github.event.pull_request.body, 'Amendment') ||
63          contains(github.event.pull_request.body, 'Removal') ||
64          contains(github.event.pull_request.body, 'Spelling or Grammar') ||
65          contains(github.event.pull_request.body, 'Website Update') ||
66          contains(github.event.pull_request.body, 'Misc')
67        )
68      uses: peter-evans/create-or-update-comment@v2
69      with:
70        token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
71        issue-number: ${{ github.event.pull_request.number }}
72        body: |
73          Hello @${{ github.actor }} 👋
74          ${{ env.BASE_MSG }}
75          ⚠️ You must specify a category
76          Either: `Addition`, `Amendment`, `Removal`, `Spelling or Grammar`, `Website Update`, or `Misc`. 
77        
78    - name: Validate Supporting Material is Present
79      if: >
80        !contains(github.event.pull_request.body, 'Supporting Material')
81      uses: peter-evans/create-or-update-comment@v2
82      with:
83        token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
84        issue-number: ${{ github.event.pull_request.number }}
85        body: |
86          Hello @${{ github.actor }} 👋
87          ${{ env.BASE_MSG }}
88          ⚠️ If applicable, please ensure you've provided supporting material.
89          
90