mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-07-17 19:12:52 +01:00
Cleanup security clearance for PRs
- Add the `CI Approval Required` label. - Add required `permissions`. - Pin action dependencies. - Make comment message generic.
This commit is contained in:
@@ -54,20 +54,35 @@ jobs:
|
||||
security-checkpoint:
|
||||
name: Check CI Clearance
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pull-requests: write
|
||||
if: github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id && github.event.pull_request.state == 'open'
|
||||
steps:
|
||||
- name: Comment on new Fork PR
|
||||
if: github.event.action == 'opened' && !contains(github.event.pull_request.labels.*.name, 'CI Cleared')
|
||||
uses: thollander/actions-comment-pull-request@v2
|
||||
uses: thollander/actions-comment-pull-request@1d3973dc4b8e1399c0620d3f2b1aa5e795465308
|
||||
with:
|
||||
message: Thank you for contributing to tgstation-server! As this pull request is from a fork, we can't allow the CI actions which require repository secrets to run on it without approval. After a brief review to make sure you're not misusing those secrets, a maintainer will add the `CI Cleared` label to allow the CI suite to run. Maintainers, please note that any changes to workflow files will not be reflected in the CI run.
|
||||
message: Thank you for contributing to ${{ github.event.pull_request.base.repo.name }}! The workflow '${{ github.workflow }}' requires repository secrets amd will not run without approval. Maintainers can add the `CI Cleared` label to allow the CI suite to run. Please note that any changes to the workflow file will not be reflected in the CI run.
|
||||
|
||||
- name: "Remove Stale 'CI Cleared' Label"
|
||||
if: github.event.action == 'synchronize' || github.event.action == 'reopened'
|
||||
uses: actions-ecosystem/action-remove-labels@v1
|
||||
uses: actions-ecosystem/action-remove-labels@2ce5d41b4b6aa8503e285553f75ed56e0a40bae0
|
||||
with:
|
||||
labels: CI Cleared
|
||||
|
||||
- name: "Add 'CI Approval Required' Label"
|
||||
if: (github.event.action == 'synchronize' || github.event.action == 'reopened') || ((github.event.action == 'opened' || github.event.action == 'labeled') && !contains(github.event.pull_request.labels.*.name, 'CI Cleared'))
|
||||
uses: actions-ecosystem/action-add-labels@bd52874380e3909a1ac983768df6976535ece7f8
|
||||
with:
|
||||
labels: CI Approval Required
|
||||
github_token: ${{ github.token }}
|
||||
|
||||
- name: "Remove 'CI Approval Required' Label"
|
||||
if: (github.event.action == 'synchronize' || github.event.action == 'reopened') || ((github.event.action == 'opened' || github.event.action == 'labeled') && !contains(github.event.pull_request.labels.*.name, 'CI Cleared'))
|
||||
uses: actions-ecosystem/action-remove-labels@2ce5d41b4b6aa8503e285553f75ed56e0a40bae0
|
||||
with:
|
||||
labels: CI Approval Required
|
||||
|
||||
- name: Fail Clearance Check if PR has Unlabeled new Commits from Fork
|
||||
if: (github.event.action == 'synchronize' || github.event.action == 'reopened') || ((github.event.action == 'opened' || github.event.action == 'labeled') && !contains(github.event.pull_request.labels.*.name, 'CI Cleared'))
|
||||
run: exit 1
|
||||
|
||||
Reference in New Issue
Block a user