Github Actions Repo Security Options

From UVOO Tech Wiki
Revision as of 20:03, 1 October 2024 by Busk (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

https://docs.github.com/en/actions/security-for-github-actions/security-guides/security-hardening-for-github-actions

name: Restrict Pull Requests

on:
  pull_request:
    types: [opened, synchronize]

jobs:
  restrict-pr:
    runs-on: ubuntu-latest
    steps:
      - name: Check PR Author
        id: check-author
        run: |
          ALLOWED_USERS=("user1" "user2" "user3")
          PR_AUTHOR=$(jq -r .pull_request.user.login "$GITHUB_EVENT_PATH")
          if [[ ! " ${ALLOWED_USERS[@]} " =~ " ${PR_AUTHOR} " ]]; then
            echo "This user is not allowed to create pull requests."
            exit 1
          fi