Coder Social home page Coder Social logo

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

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

A GitHub Action to verify that the "safe to test" label is present if the PR is from a fork.

License: MIT License

JavaScript 100.00%
cicd github-actions pull-requests

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

verify-safe-to-test-label

A GitHub Action to verifies the "safe to test" label is assigned to a PR, if 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. Otherwise, the job should fail. This is what this GitHub Action does.

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

To remove the "safe to test" label when someone pushes a new commit to the PR, use the remove-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:
  analyze:
    runs-on: ubuntu-latest
    steps:
      # This will fail if the PR is from a fork and the "safe to test" label is
      # not present.
      - name: Ensure PR has "safe to test" label, if PR is from a fork
        uses: SharezoneApp/verify-safe-to-test-label@v1
      
      - name: Do something with secrets

Inputs

Name Description Default
label The label to remove safe to test

verify-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.