-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
1,424 additions
and
4,768 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
!.eslintrc.js | ||
/dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
"use strict"; | ||
|
||
module.exports = { | ||
env: { | ||
es6: true, | ||
}, | ||
extends: [ | ||
"plugin:unicorn/recommended", | ||
"xo", | ||
"xo-typescript", | ||
"prettier", | ||
"prettier/@typescript-eslint", | ||
], | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
ecmaVersion: 2018, | ||
project: "tsconfig.json", | ||
sourceType: "module", | ||
}, | ||
plugins: ["sort-destructure-keys", "typescript-sort-keys", "unicorn"], | ||
root: true, | ||
rules: { | ||
// @actions/github uses a lot of snake_case keys. | ||
"@typescript-eslint/camelcase": "off", | ||
// TypeScript is good at type inference and already requires types where they matter: exported symbols. | ||
"@typescript-eslint/explicit-function-return-type": "off", | ||
// We use sort-keys instead. | ||
"@typescript-eslint/member-ordering": "off", | ||
"arrow-body-style": "error", | ||
// Forbid function declarations | ||
"func-style": ["error", "expression", { allowArrowFunctions: true }], | ||
// It's fine to use await in for loops instead of Promise.all to execute promises sequentially. | ||
"no-await-in-loop": "off", | ||
"no-console": "error", | ||
// TypeScript already takes care of that. See https://github.com/bradzacher/eslint-plugin-typescript/issues/110. | ||
"no-undef": "off", | ||
"object-shorthand": [ | ||
"error", | ||
"always", | ||
{ avoidExplicitReturnArrows: true }, | ||
], | ||
"sort-destructure-keys/sort-destructure-keys": [ | ||
"error", | ||
{ caseSensitive: false }, | ||
], | ||
"sort-keys": [ | ||
"error", | ||
"asc", | ||
{ caseSensitive: false, minKeys: 2, natural: true }, | ||
], | ||
"typescript-sort-keys/interface": "error", | ||
"typescript-sort-keys/string-enum": "error", | ||
"unicorn/prevent-abbreviations": ["error", { whitelist: { args: true } }], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Autosquash | ||
on: | ||
check_run: | ||
types: | ||
- completed | ||
pull_request: | ||
types: | ||
- closed | ||
- labeled | ||
pull_request_review: | ||
types: | ||
- submitted | ||
status: {} | ||
|
||
jobs: | ||
autosquash: | ||
name: Autosquash | ||
runs-on: ubuntu-18.04 | ||
steps: | ||
- uses: tibdex/autosquash@v2 | ||
with: | ||
github_token: ${{ secrets.AUTOSQUASH_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Backport | ||
on: | ||
pull_request: | ||
types: | ||
- closed | ||
- labeled | ||
|
||
jobs: | ||
backport: | ||
runs-on: ubuntu-18.04 | ||
name: Backport | ||
steps: | ||
- name: Backport | ||
uses: tibdex/backport@v1 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: Publish | ||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
publish: | ||
name: Publish | ||
runs-on: ubuntu-18.04 | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: dylanvann/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Test | ||
on: | ||
push: | ||
branches-ignore: | ||
- master | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-18.04 | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Install | ||
run: yarn install --frozen-lockfile | ||
- name: Build | ||
run: yarn run build | ||
- name: ESLint | ||
run: yarn run eslint | ||
- name: Prettier | ||
run: yarn run check-prettier |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
/.env | ||
/coverage/ | ||
/node_modules/ | ||
/reports/ | ||
/dist | ||
/node_modules |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,11 @@ | ||
[![build status](https://img.shields.io/circleci/project/github/tibdex/backport.svg)](https://circleci.com/gh/tibdex/backport) | ||
Backport is a [JavaScript GitHub Action](https://help.github.com/en/articles/about-actions#javascript-actions) to backport a pull request by simply adding a label to it. | ||
|
||
# Goal | ||
|
||
Backport is a GitHub App, based on [Probot](https://probot.github.io/), to backport a pull request by simply adding a label to it. [Try it!](https://github.com/apps/backporting) | ||
It can backport [rebased and merged](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-request-merges#rebase-and-merge-your-pull-request-commits) pull requests with a single commit and [squashed and merged](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-request-merges#squash-and-merge-your-pull-request-commits) pull requests. It thus integrates well with [Autosquash](https://github.com/marketplace/actions/autosquash). | ||
|
||
# Usage | ||
|
||
1. :electric_plug: Install the publicly hosted [Backport GitHub App](https://github.com/apps/backporting) on your repository. | ||
1. :electric_plug: Add this [.github/workflows/backport.yml](.github/workflows/backport.yml) to your repository. | ||
2. :speech_balloon: Let's say you want to backport a pull request on a branch named `production`. Then label it with `backport production`. (See [how to create labels](https://help.github.com/articles/creating-a-label/).) | ||
3. :sparkles: That's it! When the pull request gets merged, it will be backported to the `production` branch. If the pull request cannot be backported, a comment explaining why will automatically be posted. | ||
|
||
_Note:_ multiple backport labels can be added. For example, if a pull request has the labels `backport staging` and `backport production` it will be backported to both branches: `staging` and `production`. | ||
|
||
## Demo | ||
|
||
![Backport demo](./assets/demo.gif) | ||
|
||
This pull request has two commits and targets the `development` branch. After labeling it with `backport production` and merging it, Backport automatically creates a pull request on the `production` branch by cherry-picking these two commits. | ||
|
||
# How it Works | ||
|
||
Backport relies on [`github-backport`](https://www.npmjs.com/package/github-backport) to perform all the required Git operations directly through the GitHub REST API instead of having to clone repositories on a server and executing Git CLI commands. | ||
|
||
`github-backport` is the :old_key: to being able to run Backport as a stateless, easy to maintain, and cheap to operate, GitHub App! | ||
|
||
## Which Permissions & Webhooks Is Backport Using? | ||
|
||
### Permissions | ||
|
||
- **Repository contents** _[read & write]_: because the backporting process requires creating commits and manipulating branches. | ||
- **Issues** _[read & write]_: to post comments when the backport process fails. | ||
- **Pull requests** _[read & write]_: to create new pull requests. | ||
|
||
### Webhooks | ||
|
||
- **Pull requests**: to detect when pull requests are merged or labeled. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: Backporting | ||
author: Thibault Derousseaux <[email protected]> | ||
description: Automatically backport PRs to other branches by simply labeling them. | ||
inputs: | ||
github_token: | ||
description: Token for the GitHub API. | ||
required: true | ||
runs: | ||
using: node12 | ||
main: dist/index.js | ||
branding: | ||
icon: arrow-left-circle | ||
color: purple |
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.