GithubHelp home page GithubHelp logo

sharezoneapp / remove-safe-to-test-label Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 5.69 MB

A GitHub Action to remove the "safe to test" label when the PR is from a fork.

License: MIT License

JavaScript 100.00%
cicd github-actions pull-requests

remove-safe-to-test-label's Introduction

remove-safe-to-test-label

A GitHub Action to remove the "safe to test" label when the PR is from a fork.

Motivation

When you have GitHub Actions using secrets, these secrets are not available for PRs from forks. This is a security feature of GitHub Actions. This means that if you have a GitHub Action that is triggered by a PR from a fork, it will fail.

The best solution is to not use GitHub secrets in GitHub Actions that are triggered by PRs from forks (see the blog article from GitHub Security Lab: Keeping your GitHub Actions and workflows secure Part 1: Preventing pwn requests). However, sometimes this is not possible.

A workaround is to add a label to the PR when it is safe to test. This label is added by the PR reviewer. Your jobs that are using secrets are only triggered when this label is present. However, you also need to remove this label when a new commit is pushed to the PR so that the change can be reviewed again.

This GitHub Action removes the "safe to test" label when the PR is from a fork.

To verify if jobs have the "safe to test" label, you can use the verify-safe-to-test-label GitHub Action.

Usage

on:
  # This action only works with pull_request and pull_request_target events.
  # 
  # For other events, it succeeds with exit code 0.
  pull_request: # or pull_request_target

jobs:
  # It's important that you run this job first, because you need to remove the
  # "safe to test" label when the PR comes from a fork in order to ensure that
  # every change is reviewed for security implications. Other jobs should use the
  # "needs" keyword to depend on this job.
  remove-safe-to-build-label:
    runs-on: ubuntu-latest
    permissions:
      # Required to remove the "safe to test" label
      contents: read
      pull-requests: write
    steps:
      - name: Remove "safe to test" label, if PR is from a fork
        uses: SharezoneApp/remove-safe-to-test-label@v1

Inputs

Name Description Default
label The label to remove safe to test
repo-token The GitHub token to authorize the label changes. Typically the GITHUB_TOKEN secret with contents: read and pull-requests: write access github.token

remove-safe-to-test-label's People

Contributors

nilsreichardt avatar

Watchers

 avatar

Forkers

playground-nils

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.