• Stars
    star
    162
  • Rank 232,284 (Top 5 %)
  • Language
    Python
  • Created almost 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

open a pull request when a branch is pushed or updated

Automated Branch Pull Requests

This action will open a pull request to master branch (or otherwise specified) whenever a branch with some prefix is pushed to. The idea is that you can set up some workflow that pushes content to branches of the repostory, and you would then want this push reviewed for merge to master.

Here is an example of what to put in your .github/workflows/pull-request.yml file to trigger the action.

name: Pull Request on Branch Push
on:
  push:
    branches-ignore:
      - staging
      - launchpad
      - production
jobs:
  auto-pull-request:
    name: PullRequestAction
    runs-on: ubuntu-latest
    steps:
      - name: pull-request-action
        uses: vsoch/pull-request-action@master
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          BRANCH_PREFIX: "update/"
          PULL_REQUEST_BRANCH: "master"

Important: Make sure to use a stable release instead of a branch for your workflow.

Environment Variable Inputs

Unlike standard actions, this action just uses variables from the environment.

Name Description Required Default
BRANCH_PREFIX the prefix to filter to. If the branch doesn't start with the prefix, it will be ignored false ""
PULL_REQUEST_REPOSITORY Choose another repository instead of default GITHUB_REPOSITORY for the PR false
PULL_REQUEST_TOKEN Personal Access Token(PAT) only if you define a different repository with PULL_REQUEST_REPOSITORY false
PULL_REQUEST_BRANCH open pull request against this branch false master
PULL_REQUEST_FROM_BRANCH if a branch isn't found in your GitHub payload, use this branch false
PULL_REQUEST_BODY the body for the pull request false
PULL_REQUEST_TITLE the title for the pull request false
PULL_REQUEST_DRAFT should this be a draft PR? false unset
MAINTAINER_CANT_MODIFY Do not allow the maintainer to modify the PR false unset
PULL_REQUEST_ASSIGNEES A list (string with spaces) of users to assign false unset
PULL_REQUEST_REVIEWERS A list (string with spaces) of users to assign review false unset
PULL_REQUEST_TEAM_REVIEWERS A list (string with spaces) of teams to assign review false unset
PASS_ON_ERROR Instead of failing on an error response, pass false unset
PASS_IF_EXISTS Instead of failing if the pull request already exists, pass false unset
PULL_REQUEST_UPDATE If the pull request already exists, update it false unset
PULL_REQUEST_STATE If PULL_REQUEST_UPDATE is true, update to this state (open, closed) false open

For PULL_REQUEST_DRAFT, PASS_ON_ERROR, PASS_IF_EXISTS, and MAINTAINER_CANT_MODIFY, these are treated as environment booleans. If they are defined in the environment, they trigger the "true" condition. E.g.,:

  • Define MAINTAINER_CANT_MODIFY if you don't want the maintainer to be able to modify the pull request.
  • Define PULL_REQUEST_DRAFT if you want the PR to be a draft.
  • Define PASS_ON_ERROR if you want the PR to not exit given any non 200/201 response.
  • Define PASS_IF_EXISTS if you want the PR to not exit given the pull request is already open.
  • Define PULL_REQUEST_UPDATE if you want the pull request to be updated if it already exits.

For PULL_REQUEST_ASSIGNEES, PULL_REQUEST_REVIEWERS, and PULL_REQUEST_TEAM_REVIEWERS you can provide a string of one or more GitHub usernames (or team names) to assign to the issue. Note that only users with push access can add assigness to an issue or PR, they are ignored otherwise.

The GITHUB_TOKEN secret is required to interact and authenticate with the GitHub API to open the pull request. The example is deployed here with an example opened (and merged) pull request here if needed.

If you want to create a pull request to another repository, for example, a pull request to the upstream repository, you need to define PULL_REQUEST_REPOSITORY and PULL_REQUEST_TOKEN. The PULL_REQUEST_TOKEN is one Personal Access Token(PAT), which can be save in the encrypted secrets

Outputs

The action sets a few useful output and environment variables. An output can be referenced later as ${{ steps.<stepname>.outputs.<output-name> }}. An environment variable of course can be referenced as you usually would.

Name Description Environment
pull_request_number If the pull request is opened, this is the number for it. PULL_REQUEST_NUMBER
pull_request_url If the pull request is opened, the html url for it. PULL_REQUEST_URL
pull_request_return_code Return code for the pull request PULL_REQUEST_RETURN_CODE
assignees_return_code Return code for the assignees request ASSIGNEES_RETURN_CODE
reviewers_return_code Return code for the reviewers request REVIEWERS_RETURN_CODE

See the examples/outputs-example.yml for how this works. In this example, we can reference ${{ steps.pull_request.outputs.pull_request_url }} in either another environment variable declaration, or within a run statement to access our variable pull_request_url that was generated in a step with id pull_request. The screenshot below shows the example in action to interact with outputs in several ways.

img/outputs.png

Examples

Example workflows are provided in examples, and please contribute any examples that you might have to help other users! You can get the same commit hashes and commented tags if you use the action-updater also maintained by @vsoch. We will walk through a basic example here for a niche case. Let's say that we are opening a pull request on the release event. This would mean that the payload's branch variable would be null. We would need to define PULL_REQUEST_FROM. How would we do that? We can set environment variables for next steps. Here is an example:

name: Pull Request on Branch Push
on: [release]
jobs:
  pull-request-on-release:
    name: PullRequestAction
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Code
        uses: actions/checkout@v2
      - name: Derive from branch name
        run: |
            # do custom parsing of your code / date to derive a branch from
            PR_BRANCH_FROM=release-v$(cat VERSION)
            echo "PULL_REQUEST_FROM_BRANCH=${PR_BRANCH_FROM}" >> $GITHUB_ENV
      - name: pull-request-action
        uses: vsoch/pull-request-action@master
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          PULL_REQUEST_BRANCH: "master"

The above workflow is triggered on a release, so the branch will be null in the GItHub payload. Since we want the release PR to come from a special branch, we derive it in the second step, and then set the PULL_REQUEST_FROM_BRANCH variable in the environment for the next step. In the Pull Request Action step, the pull request will be opened from PULL_REQUEST_FROM_BRANCH against PULL_REQUEST_BRANCH, which is master. If we do not set this variable, the job will exit in an error, as it is not clear what action to take.

Example use Case: Update Registry

As an example, I created this action to be intended for an organizational static registry for container builds. Specifically, you have modular repositories building container recipes, and then opening pull requests to the registry to update it.

  • the container collection content should be generated from a separate GitHub repository, including the folder structure (manifests, tags, collection README) that are expected.
  • the container collection metadata is pushed to a new branch on the registry repository, with namespace matching the GitHub repository, meaning that each GitHub repository always has a unique branch for its content.
  • pushing this branch that starts with the prefix (update/) triggers the GitHub actions to open the pull request.

If the branch is already open for PR, it updates it. Take a look at this example for the pull request opened when we updated the previous GitHub syntax to the new yaml syntax. Although this doesn't describe the workflow above, it works equivalently in terms of the triggers.

More Repositories

1

watchme

Reproducible watchers for research
HTML
784
star
2

docsy-jekyll

A Jekyll version of the beautiful Docsy!
CSS
182
star
3

django-nginx-upload

example of using nginx upload module with Django!
Python
74
star
4

mkdocs-jekyll

The Material theme from MkDocs provided as a Jekyll template, optimized for GitHub Pages
JavaScript
62
star
5

pokemon

ascii database of pokemon... in python!
Python
57
star
6

forward

Port Forwarding Utility
Shell
42
star
7

hospital-chargemaster

hospital chargemaster lists for open source healthcare
Python
35
star
8

regression-wasm

Testing doing basic regression with web assembly
Go
32
star
9

scif

scientific filesystem: a filesystem organization for scientific software and metadata
Python
30
star
10

tw-jekyll

A jekyll-ized documentation theme using tailwind.css based on Fly.io's theme
HTML
20
star
11

ood-compose

Docker compose to bring up Open OnDemand with SLURM, Centos 7
Shell
20
star
12

oci-python

Python implementation of Open Containers Initiative (OCI) specifications
Python
18
star
13

TtoZ

Convert T score brain statistical map to Z score map
Python
16
star
14

pybraincompare

brain image comparison and visualization methods for python!
HTML
16
star
15

singularity-shiny

a quick shiny server in a Singularity Container. For @griznog!
Shell
15
star
16

qme

QueueMe is a job queue, manager, and dashboard
Python
12
star
17

convert-swf

a container to convert swf files to mp4 (video)
Dockerfile
12
star
18

django-oci

Open Containers distribution spec module for Django (under development)
Python
11
star
19

vsoch.github.io

Hi, I'm Vanessa (vsoch, the Vanessasaurus) and this is where I write things.
JavaScript
10
star
20

lessons

quick lessons for reproducible research practices
HTML
10
star
21

helpme

command line daemon for helping you out
Python
9
star
22

askci

version controlled knowledge base for documentation and support
Python
9
star
23

citelang

markdown syntax and credit system for software!
Python
9
star
24

singularity-web

examples of using Singularity containers for web-based products
HTML
8
star
25

django-river-ml

Django plugin for online machine learning with river (under-development)
Python
8
star
26

watchme-system

An example reproducible monitor for system metrics using the watchme client
Jupyter Notebook
7
star
27

docker-pull

Save your Docker Hub containers from ultimate doom!
7
star
28

banner-maker

Dynamically generate svg banner with text content (flask application)
HTML
7
star
29

som

Stanford open modules for python
Python
7
star
30

search

a search interface for any user account or organization
JavaScript
6
star
31

ica-

Melodic + Dual Regression Package in Python
Python
6
star
32

cogat-docker

testing implementation of Cognitive Atlas as neo4j served with docker, for some application
CSS
6
star
33

contributions-django

Django module to create GitHub style contributions graph
Python
6
star
34

codeart

data visualization for code (experimental project)
Python
6
star
35

containershare

open source, transparent container registry for reproducible science
TeX
6
star
36

google-group-export

An interactive script to export a Google Group
Python
6
star
37

action-updater

Update your GitHub actions' versions, syntax, and other!
Python
5
star
38

confucious-actions

Various actions to add confucious wisdom on pull request success, fail, etc.
Shell
5
star
39

containertree

Github action example to deploy container-diff derived tree to Github pages, along with container metadata
HCL
5
star
40

libabigail-python

testing python bindings for libabigail
Python
5
star
41

sb-admin-jekyll

Bootstrap 4 theme, sb-admin, Jekyll version
CSS
5
star
42

sifweb

Testing loading a SIF into a browser using Web Assembly (under development)
Go
5
star
43

40-avocados

Many ways I could spend $40.00
Python
5
star
44

resource-explorer

Select a resource or service based on filtering down criteria
CSS
5
star
45

som-orthanc

A Docker base for running Orthanc for the School of Medicine
Python
4
star
46

github-dockerfiles

A dataset to extract container metadata from Github Dockerfiles (under development)
Shell
4
star
47

chonker-awards

A shoutout to the top chonker repositories on GitHub.
CSS
4
star
48

codeart-examples

Separate examples repository for codeart Python module, since data and image files tend to be large.
HTML
4
star
49

lolcow-operator

My first Kubernetes operator! (under development)
HTML
4
star
50

brainart

create a mosaic of brain images to match any image template
HTML
4
star
51

datasets

open source datasets for machine learning, the dinosaur datasets
HTML
4
star
52

notes-jekyll

A jekyll theme optimized for reference management and note taking
HTML
4
star
53

pyCorr

Nifti Template Matching in Python
Python
4
star
54

elfcall

Testing a library to generate trees and graphs from ELF
Python
3
star
55

juliart

module for generating Julia Set artwork
Python
3
star
56

noisecloud-www

deprecated web interface for noisecloud (previously wordpress) interface
HTML
3
star
57

pe-predictive

Python
3
star
58

fvplay

MATLAB scripts is intended for visualizing and preparing raw data for use with a supervised classifier
MATLAB
3
star
59

ohbm

python api wrapper for the ohbm conference
Python
3
star
60

asciiquarium

A docker container to run the beloved asciiquarium. Because you can't kill these fish.
Dockerfile
3
star
61

nushell-plugin-python

Python module for easy creation of nushell plugins
Python
3
star
62

cdb

Container database metadata extraction and data-container builder
Python
3
star
63

dinosaur-lessons

dinosaur is teaching!
Jupyter Notebook
3
star
64

puzzles

robot puzzle solver, maybe
Python
3
star
65

nidmviewer

NIDM Results Viewer
CSS
3
star
66

dinosaur-dilemma

attempt at a fun simulation to evolve avocado eating dinosaurs
Python
3
star
67

make-me-a-sandwich

Python to javascript sandwich matching game. Becaue we need this now.
Python
3
star
68

robots

I got distracted 10 hours ago, and this is what happened.
CSS
3
star
69

caliper

Caliper is a tool for measuring and assessing change in packages.
Python
3
star
70

learning-rust

*insert no idea what he's doing dog*
Rust
3
star
71

uptodate

Client and GitHub action to keep repository contents up to date (currently support for Docker)
Go
3
star
72

natacha-bot

The natacha bot has opinions about politics and art.
Lua
3
star
73

thesis

html generator for a latex (zipped) thesis from Overleaf
Python
3
star
74

gene2drug

A toolbox to find if gene sets and drugs are meaningfully related [in development]
R
3
star
75

contributor-ci

tools and resources for assessing contributions
JavaScript
3
star
76

markovmeme

Generate memes using Markov Models
Python
3
star
77

pytest-github-report

Generate markdown report for pytest tests in GitHub actions
Python
3
star
78

clingo-lessons

Slowly learning clingo, and writing notebooks that walk you through logic programs (under development)
Jupyter Notebook
3
star
79

nu-plugin

GoLang library for creating nushell plugins (under development!)
Go
3
star
80

vbmis.com

deprecated content from an old website, for archive
HTML
3
star
81

repo2docker-r

a template for sharing a repo2docker R container, intended for use with https://vsoch.github.io/containershare
Jupyter Notebook
3
star
82

DisorderBehavior

Methods to link disorders to behaviors, and do disorder comparison
Python
3
star
83

nushell-debian

Debian build (based on nushell/nushell) for nu! (under development)
Makefile
3
star
84

singularity-tools

collection of command line tools for working with Singularity and Docker
Python
3
star
85

nushell-plugin-pokemon

An example plugin for Nushell in Python that catches ascii pokemon
Python
2
star
86

candy-generator

Preparing for a fun, open source Halloween!
JavaScript
2
star
87

dna-seq

2
star
88

containers-story

A story of how people influence software design.
JavaScript
2
star
89

elm-app-catalog

testing development of an app catalog with elm (under development)
HTML
2
star
90

gridtest

grid parameters and testing for Python modules and functions
HTML
2
star
91

griznog

Griznog, eternally trapped in Python, and a container for forever access to his wisdom.
Python
2
star
92

qt-creator

trying to build qt-creator into a Docker container for easy usage.
Shell
2
star
93

repofish

search github repos for python functions and generate standard data structures for them
Python
2
star
94

boneage

A django application to demo a bone age prediction model
Python
2
star
95

docker-permissions

A quick example to show building with a user/group id, and creating files that aren't root owned
Dockerfile
2
star
96

nushell-plugin-len

An example ls plugin for nushell using golang
Go
2
star
97

insult-go

generate Shakespearean insults with GoLang and Web Assembly. Because why not.
Go
2
star
98

freegenes

FreeGenes BioNode with Django
JavaScript
2
star
99

wiki

legacy wiki from pre and early graduate school
MATLAB
2
star
100

MRtools

Module for neuroimaging data manipulation and sample applications
Python
2
star