Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A Github application that cancels unauthorized workflow runs.

NotificationsYou must be signed in to change notification settings

eladchen/protected-workflows

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Protected Workflows is aGithub application. Its goal is to cancelunauthorized workflow runs.

Table of Contents

What Is the Purpose of This Repository

This repository is the offical place to view the documentation and report issues regardingProtected-Workflows.

Features

  1. Cancelunauthorized workflow runs
  2. Write configuration using YAMLwith anchors & aliases support.
  3. Combine and mix the following parameters to authorize workflow runs:
    1. The user name
    2. Whether the triggering user is:
      • Acollaborator (requires "admin" or "write" permission).
      • A member of the organisation (If the repository is owned by an organisation)
      • Coming Soon - A member of a certain team (Note: teams feature is limited to organisation/enterprise repositories)
    3. Changed files paths (Limited to workflow runs triggered by "push", "pull_request" or "pull_request_target")

How Does This Application Work

Whenever a workflow run is triggered the application will be notified by github, and will use the application
configuration to authorize the workflow run. Unauthorized workflow runs will be canceled.

When Is a Workflow Run "Unauthorized"?

When not a singlerule authorized the workflow run.

Configuration

Configuration is to be written to a file using YAML, and stored within therepository root under.github/protected-workflows.yml.

The YAML may contain two top level properties:

  • "events" which is a map betweenGithub event names and rules
  • "anyEvent" which will be used as a fallback rule when event specific rules are undefined

Rule

A "Rule" is an object made up of the following properties:

PropertyDescriptionTypeDefault
trustAnyoneAuthorize workflow runs triggered by any actorbooleanfalse
trustCollaboratorsAuthorize workflow runs triggered by collaboratorsbooleanfalse
trustOrgMembersAuthorize workflow runs triggered by organisation membersbooleanfalse
trustedUserNamesAuthorize workflow runs triggered by predefined user namesstring[][]
pathsAuthorize workflow runs by changed paths. Can only be used with "push", "pull_request" and "pull_request_target" eventsPathsPaths

Paths:

PropertyDescriptionTypeDefault
allowedWhat paths may be changedstring[][]
disallowedWhat paths may not change. Glob patterns are supportedstring[][]

Complete example:

# "events" is a map between Github events and rules.# possible event names can be seen at https://docs.github.com/en/actions/reference/events-that-trigger-workflowsevents:# 'pull_request' is the Github event name.# '&pull_request' is a YAML anchorpull_request:&pull_request# Authorize any user when package.json or anything under .github folder was not changed.    -trustAnyone:truepaths:disallowed:          -".github/**"          -"package.json"# Authorize "bot" user when CHANGELOG.md is the only changed file.    -trustedUserNames:        -"bot"paths:allowed:          -"CHANGELOG.md"# Authorize collaborators when package.json is the only changed file.    -trustCollaborators:truepaths:allowed:          -"package.json"# Reference the "pull_request" anchor to reuse its configuration# Read about "pull_request_target" in this blog post:# https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/pull_request_target:*pull_request# 'anyEvent' value is a rule, and will be used when an event specific configuration is not set.# It is automatically added in case it was not explictly set and it does not supports the 'paths' property.anyEvent:trustAnyone:falsetrustCollaborators:falsetrustedUserNames:[]

Attention:Workflow runs will be cancelled only if all rules deemed the workflow is unauthorized

Best Practices

  • Make sure only specific users are allowed to change the configuration file: .github/protected-workflows.yml.Example

  • Use the same rules for "pull_request", "pull_request_target" & "push". (Avoid repeating yourself by usinganchors and aliases)

  • Identify build, release and dependency manifest files and limit who can change them to specific users

    Example of what such files may be are:

    • Files under the .github/workflows directory
    • Release Scripts
    • A Dockerfile
    • Dependencies files (package.json, package-lock.json, build.gradle etc...)

Usage

  1. Install the app
  2. Create a configuration file using the above guidelines and store it within the repository root under.github/protected-workflows.yml

About

A Github application that cancels unauthorized workflow runs.

Topics

Resources

Stars

Watchers

Forks


[8]ページ先頭

©2009-2025 Movatter.jp