.github | ||
.husky | ||
dist | ||
src | ||
test | ||
.commitlintrc.json | ||
.eslintignore | ||
.eslintrc | ||
.gitignore | ||
.release-it.json | ||
action.yml | ||
CHANGELOG.md | ||
jest.config.ts | ||
LICENSE | ||
package-lock.json | ||
package.json | ||
README.md | ||
tsconfig.json |
BPER: Git Backporter
📤 📥
BPer is a NodeJS command line tool that provides capabilities to backport [1] pull requests in an automated way. This tool also comes with a predefined GitHub action in order to make CI/CD integration easier for all users.
[1] backporting is an action aiming to move a change (usually a commit) from a branch (usually the main one) to another one, which is generally referring to a still maintained release branch. Keeping it simple: it is about to move a specific change or a set of them from one branch to another.
Table of content
Usage
This tool is released on the public npm registry, therefore it can be easily installed using npm
:
$ npm install -g @lampajr/bper
Then it can be used as any other command line tool:
$ bper -tb <branch> -pr <pull-request-url> -a <github-token> [-f <your-folder>]
Inputs
This toold comes with some inputs that allow users to override the default behavior, here the full list of available inputs:
Name | Command | Required | Description | Default |
---|---|---|---|---|
Version | -V, --version | - | Current version of the tool | |
Help | -h, --help | - | Display the help message | |
Target Branch | -tb, --target-branch | Y | Branch where the changes must be backported to | |
Pull Request | -pr, --pull-request | Y | Original pull request url, the one that must be backported, e.g., https://github.com/lampajr/backporting/pull/1 | |
Auth | -a, --auth | N | GITHUB_TOKEN or a repo scoped Personal Access Token |
"" |
Folder | -f, --folder | N | Local folder where the repo will be checked out, e.g., /tmp/folder | {cwd}/bp |
Dry Run | -d, --dry-run | N | If enabled the tool does not push nor create anything remotely, use this to skip PR creation | false |
GitHub Action
This action can be used in any GitHub workflow, below you can find a simple example of manually triggered workflow backporting a specific pull request (provided as input).
name: Pull Request Backporting using BPer
on:
workflow_dispatch:
inputs:
targetBranch:
description: 'Target branch'
required: true
type: string
pullRequest:
description: 'Pull request'
required: true
type: string
dryRun:
description: 'Dry run'
required: false
default: "true"
type: string
jobs:
backporting:
name: "Backporting"
runs-on: ubuntu-latest
steps:
- name: Backporting
uses: lampajr/backporting@main
with:
target-branch: ${{ inputs.targetBranch }}
pull-request: ${{ inputs.pullRequest }}
auth: ${{ secrets.GITHUB_TOKEN }}
dry-run: ${{ inputs.dryRun }}
You can also use this action with other events - you'll just need to specify target-branch
and pull-request
params.
For a complete description of all inputs see Inputs section.
Limitations
BPer is in development mode, this means that it has many limitations right now. I'll try to summarize the most importan ones:
- No way to override backporting pull request fields like body, reviewers and so on.
- You can backport pull requests only.
- It only works for GitHub.
- Integrated in GitHub Actions CI/CD only.
Based on these limitations, the next Future Works could be the following:
- Give users the possibility to override/customize the backporting pull request.
- Provide a way to backport single commit too (or a set of them), even if no original pull request is present.
- Integrate this tool with other git management services (like GitLab and Bitbucket) to make it as generic as possible.
- Provide some reusable GitHub workflows.
Contributing
This is an open source project, and you are more than welcome to contribute ❤️!
Every change must be submitted through a GitHub pull request (PR). Backporting uses continuous integration (CI). The CI runs checks against your branch after you submit the PR to ensure that your PR doesn’t introduce errors. If the CI identifies a potential problem, our friendly PR maintainers will help you resolve it.
Note
: this project follows git-conventional-commits standards, thanks to the commit-msg hook you are not allowed to use commits that do not follow those standards.
-
Fork it (https://github.com/lampajr/backporting).
-
Create your feature branch: (git checkout -b feature).
-
Commit your changes with a comment: (git commit -am 'Add some feature').
-
Push to the branch to GitHub: (git push origin feature).
-
Create a new pull request against
main
branch.
Note
: you don't need to take care about typescript compilation and minifycation, there are automated git hooks taking care of that!
License
Backporting (BPer) open source project is licensed under the MIT license.