Skip to content

A basic GitHub Action to create and update PullRequests from a source to a target branch.

License

Notifications You must be signed in to change notification settings

mkarle/pr-update

 
 

Repository files navigation

PR-Update

License GitHub release (latest by date)

Introduction

This is a very basic GitHub Action to simply update a GitHub Pull Request from an existing branch of the given repository to another one. This Action does not commit any of your changes, nor does it create any of the branches it uses. All this action does is update a Pull Request, nothing more.

Note
This Action took inspiration of several other PR creating and updating Actions, however none of them seemed to be doing what I needed, so this exists now.

Action I/O

Tip

It is recommended that you lock down the permissions granted to the default GITHUB_TOKEN within any workflow you have in your repositories.

This action will need at least these permissions set on the workflow it runs in:

permissions:
  contents: read
  pull-requests: write

Action Inputs

Input Required Description

token

true

The GitHub Token to use by this Action (e.g. ${{ secrets.GITHUB_TOKEN }})

pr_title

true

The title of the PR that should be created/updated (e.g. My awesome PR)

pr_number

true

The pull request number used to fetch the PR to update

pr_body

false

The body of the PR to create (e.g. My very useful PR description)

pr_body_with_links

false

When enabled appends links of associated PRs to the body of the PR to create (e.g. - [My new feature](https://github.com/k3rnels-actions/pr-update/pulls/1))

pr_labels

false

A comma separated list of labels to add to the PR (e.g. label0,label1)

pr_assignees

false

A comma separated list of assignees to add to the PR (e.g. octocat)

pr_update_type

false

The type of update to perform on the PR (e.g. prefix, suffix, replace). Defaults to suffix

Action Outputs

Output Description

pr_nr

The number of the created/updated PR

Usage

create-or-update-pr.yml
on:
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v2
      - name: Do some changes to the repo
        run: ...
      - name: Run Git CCommands
        run: |
          git checkout -b branch_name
          git commit -am 'add som stuff'
          git push origin
      - name: Update PR
        uses: k3rnels-actions/pr-update@v1
        id: pr_update
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          pr_title: Awsome PR
          pr_number: ${{ github.event.pull_request.number }}
          pr_body: |
            ### Description
            Yes you can use Markdown here too
            ### Changes
            The following features have been added:\r\n
          pr_body_with_links: true

      - name: Upload Artifact
        run: echo "${{ steps.pr_update.outputs.pr_nr }}"

Contribute

All kinds of contributions are more than welcome! However, if you plan bigger changes please open an issue first to discuss your proposed changes 😉

Licence

This project is licenced under the GPLv3 or later.

About

A basic GitHub Action to create and update PullRequests from a source to a target branch.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 97.3%
  • JavaScript 2.0%
  • Shell 0.7%