Sign inSign up

sgibson91/test-this-pr-action

By sgibson91

•Updated over 3 years ago

Image
0

910

sgibson91/test-this-pr-action repository overview

⁠Test this PR! - Docker-based Action

CI Tests pre-commit.ci status

The fork --> develop --> open pull request workflow is a popular one across large software projects. However if you have tests that require secrets, such as deploying to staging environments before production, this workflow can be a hindrance when managing that workflow through GitHub Actions, since the runner doesn't automatically grant access to repository secrets.

This repository is a Docker-based GitHub Action that will push the changes of a pull request opened from a fork into a new branch in the parent repo so test workflows that require secrets can be executed.

You will need to create a GitHub access token with enough permissions to write to the parent repo and save this as a repository secret. If the parent repo is public, public_repo should be enough.

⁠Inputs

Input variableDescriptionRequired?Default value
access_tokenA GitHub token with read/write access to the parent repositoryYes
repositoryThe name of the parent repository in the form owner/projectNo${{ github.repository }}
pr_numberThe number of the Pull Request to be testedNo${{ github.event.issue.number }}

⁠Example Usage

The below example demonstrates how to trigger the GitHub Action by leaving a comment containing /test-this-pr on a pull request, providing the comment author has appropriate permissions on the parent repository.

NOTE: These permissions are provided as an example only and users should carefully read the GitHub documentation⁠ before deciding which roles to use.

name: Move forked-PR into parent repo for testing

on:
  issue_comment:
    types: [created]

jobs:
  test-this-pr:
    runs-on: ubuntu-latest
    if: |
      # Check this issue is a pull request
      (github.event.issue.pull_request != null) &&
      # Check the comment contains the trigger string
      contains(github.event.comment.body, '/test-this-pr') &&
      # Check the comment author has appropriate permissions
      contains(
        github.event.comment.author_association,
        ['OWNER', 'COLLABORATOR', 'MEMBER']
      )

    steps:
      - uses: sgibson91/test-this-pr-action@main
        with:
          access_token: ${{ secrets.ACCESS_TOKEN }}

Tag summary

Content type

Image

Digest

sha256:b5837f7bd…

Size

53.6 MB

Last updated

over 3 years ago

docker pull sgibson91/test-this-pr-action