Coder Social home page Coder Social logo

budde377 / pr-update-action Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tzkhan/pr-update-action

0.0 1.0 0.0 10.82 MB

GitHub Action that updates a pull request with information extracted from branch name

License: MIT License

JavaScript 100.00%

pr-update-action's Introduction

Pull Request Updater

This is a GitHub Action that updates a pull request with information extracted from branch name.

Usage

Create Workflow

Create a workflow yaml file (eg: .github/workflows/update-pr.yml see Creating a Workflow file):

name: "Update Pull Request"

on: pull_request

jobs:
  update_pr:
    runs-on: ubuntu-latest
    steps:
    - uses: tzkhan/pr-update-action@v1
      with:
        repo-token: "${{ secrets.GITHUB_TOKEN }}"                   # required - allows the action to make calls to GitHub's rest API
        branch-regex: 'FOO-\d+'                                     # required - regex to match text from the head branch name
        lowercase-branch: true                                      # optional - whether to lowercase branch name before matching
        title-template: '[%branch%]'                                # optional - text template to prefix title
        title-prefix-space: true                                    # optional - whether to add a space after title prefix
        uppercase-title: true                                       # optional - whether to uppercase title prefix
        body-template: '[%branch%](https://browse/ticket/%branch%)' # optional - text template to prefix body
        body-prefix-newline-count: 2                                # optional - number of newlines to insert after body prefix
        uppercase-body: true                                        # optional - whether to uppercase body prefix

body-template can be set to a GitHub secret if necessary to avoid leaking sensitive data in the URLs for instance. body-template: ${{ secrets.PR_BODY_PREFIX_TEMPLATE }}

NOTE: template values must contain the %branch% token (can occur multiple times) so that it can be replaced with the matched text from the branch name.

Example

So the following yaml

name: "Update Pull Request"
on: pull_request

jobs:
  pr_update_text:
    runs-on: ubuntu-latest
    steps:
    - uses: tzkhan/pr-update-action@v1
      with:
        repo-token: "${{ secrets.GITHUB_TOKEN }}"
        branch-regex: 'foo-\d+'
        lowercase-branch: false
        title-template: '[%branch%]'
        title-prefix-space: true
        uppercase-title: true
        body-template: '[Link to %branch%](https://url/to/browse/ticket/%branch%)'
        body-prefix-newline-count: 2
        uppercase-body: true

produces this effect... ๐Ÿ‘‡

before:

pr before

after:

pr after

pr-update-action's People

Contributors

ivanbanov avatar tzkhan avatar

Watchers

 avatar

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.