An open API service indexing awesome lists of open source software.

https://github.com/k3rnels-actions/pr-update

A basic GitHub Action to create and update PullRequests from a source to a target branch.
https://github.com/k3rnels-actions/pr-update

actions github github-actions pull-requests typescript-action

Last synced: 6 months ago
JSON representation

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

Awesome Lists containing this project

README

          

[[pr-update]]
= PR-Update
:toc: macro
:toc-title:

image:https://img.shields.io/github/workflow/status/k3rnels-actions/pr-update/build-test.svg?label=build-test[GitHub Workflow Status, link="https://github.com/k3rnels-actions/pr-update/actions/workflows/test.yml"]
image:https://img.shields.io/codefactor/grade/github/k3rnels-actions/pr-update.svg[CodeFactor, link="https://www.codefactor.io/repository/github/k3rnels-actions/pr-update"]
image:https://img.shields.io/maintenance/yes/2030.svg[Maintenance status, link="https://github.com/k3rnels-actions/pr-update"]
image:https://img.shields.io/github/license/k3rnels-actions/pr-update.svg[License, link="https://github.com/k3rnels-actions/pr-update/blob/main/LICENSE"]
image:https://img.shields.io/github/v/release/k3rnels-actions/pr-update.svg[GitHub release (latest by date), link="https://github.com/k3rnels-actions/pr-update/releases"]

[#introduction]
== Introduction

This is a very basic GitHub Action to simply create a GitHub Pull Request form 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 create 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-io]
== 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:

[source,yaml]
----
permissions:
contents: read
pull-requests: write
----

====

=== Action Inputs

[cols="1,^1,4"]
|===
|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_source`
|`true`
|The source branch name the PR should have (this branch needs to already exist in the repository)

|`pr_target`
|`false`
|The target branch name the PR should have (defaults to the default branch of the repo)

|`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`)
|===

=== Action Outputs

[cols="1,2"]
|===
|Output |Description

|`pr_nr`
|The number of the created/updated PR
|===

[#usage]
== Usage

.create-or-update-pr.yml
[source,yaml]
----
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: Create-Update PR
uses: k3rnels-actions/pr-update@v1
id: pr_update
with:
token: ${{ secrets.GITHUB_TOKEN }}
pr_title: Awsome PR
pr_source: branch_name
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]
== 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 :wink:

[#licence]
== Licence

image::https://www.gnu.org/graphics/gplv3-or-later.svg[link="https://opensource.org/licenses/GPL-3.0"]

Just if the badge from `shields.io` and the link:LICENSE[] file do not make it obvious enough, this project is licenced under the link:https://opensource.org/licenses/GPL-3.0[GPLv3] or later.