Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate upstream changes #27

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
55 changes: 0 additions & 55 deletions .eslintrc.js

This file was deleted.

22 changes: 0 additions & 22 deletions .github/workflows/autosquash.yml

This file was deleted.

18 changes: 14 additions & 4 deletions .github/workflows/backport.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
name: Backport
on:
pull_request:
pull_request_target:
types:
- closed
- labeled

jobs:
backport:
runs-on: ubuntu-18.04
name: Backport
runs-on: ubuntu-latest
# Only react to merged PRs for security reasons.
# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target.
if: >
github.event.pull_request.merged
&& (
github.event.action == 'closed'
|| (
github.event.action == 'labeled'
&& contains(github.event.label.name, 'backport')
)
)
steps:
- name: Backport
uses: tibdex/backport@v1
- uses: tibdex/backport@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ name: Publish
on:
push:
branches:
- master
- main

jobs:
publish:
name: Publish
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- uses: dylanvann/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
19 changes: 8 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@ name: Test
on:
push:
branches-ignore:
- master
- main

jobs:
test:
name: Test
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
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
- uses: actions/checkout@v3
- run: yarn install --frozen-lockfile
- run: yarn run yarn-deduplicate --strategy fewer --fail
- run: yarn run build
- run: yarn run prettier --check
- run: yarn run xo
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
The MIT License (MIT)
Copyright (c) 2020 Thibault Derousseaux <[email protected]>
Copyright (c) 2023 Thibault Derousseaux <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ It thus integrates well with [Autosquash](https://github.com/marketplace/actions
# Usage

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.

Expand Down
53 changes: 45 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,56 @@
name: Backporting
author: Thibault Derousseaux <[email protected]>
description: Automatically backport PRs to other branches by simply labeling them.
description: >
Automatically backport PRs to other branches by simply labeling them.
inputs:
add_labels:
description: Comma separated list of labels to add to the backport PR.
required: false
body_template:
description: >
Lodash template for the backport PR's body.

The data properties are:
- base: backport PR's base branch
- body: original PR's body
- mergeCommitSha: SHA of the original PR's merge commit
- number: original PR's number
default: "Backport <%= mergeCommitSha %> from #<%= number %>."
github_token:
description: Token for the GitHub API.
required: true
head_template:
description: >
Lodash template for the backport PR's head branch.

The data properties are:
- base: backport PR's base branch
- number: original PR's number
default: "backport-<%= number %>-to-<%= base %>"
label_pattern:
description: >
The regular expression pattern that PR labels will be tested on to decide whether the PR should be backported and where.
The backport PR's base branch will be extracted from the pattern's required `base` named capturing group.
default: "^backport (?<base>([^ ]+))$"
labels_template:
description: >
Lodash template compiling to a JSON array of labels to add to the backport PR.

The data properties are:
- base: backport PR's base branch
- labels: array containing the original PR's labels, excluding those matching `label_pattern`.
default: "[]"
title_template:
description: Template for the title of the backport PR.
required: false
default: "[Backport {{base}}] {{originalTitle}}"
description: >
Lodash template for the backport PR's title.

The data properties are:
- base: backport PR's base branch
- number: original PR's number
- title: original PR's title
default: "[Backport <%= base %>] <%= title %>"
outputs:
created_pull_requests:
description: A JSON stringified object mapping the base branch of the created pull requests to their number.
runs:
using: node12
using: node16
main: dist/index.js
branding:
icon: arrow-left-circle
Expand Down
58 changes: 29 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
{
"name": "backport",
"version": "1.1.1",
"version": "2.0.4",
"license": "MIT",
"main": "dist/index.js",
"type": "module",
"files": [
"action.yml",
"dist"
],
"main": "dist/index.js",
"scripts": {
"build": "ncc build src/index.ts --minify --v8-cache",
"check-prettier": "yarn run prettier --check",
"eslint": "eslint --ignore-path .gitignore --max-warnings 0 \"./**/*.{js,ts}\"",
"format-prettier": "yarn run prettier --write",
"prettier": "prettier --ignore-path .gitignore \"./**/*.{js,json,md,ts,yml}\""
"prebuild": "tsc --build",
"build": "ncc build src/index.ts --minify --target es2022 --v8-cache",
"prettier": "prettier --ignore-path .gitignore \"./**/*.{cjs,js,json,md,ts,yml}\"",
"xo": "xo"
},
"dependencies": {
"@actions/core": "^1.10.0",
"@actions/exec": "^1.1.1",
"@actions/github": "^5.1.1",
"ensure-error": "^4.0.0",
"lodash-es": "^4.17.21"
},
"devDependencies": {
"@actions/core": "^1.2.6",
"@actions/exec": "^1.0.4",
"@actions/github": "^4.0.0",
"@octokit/webhooks": "^7.15.1",
"@types/lodash": "^4.14.164",
"@types/node": "^14.14.6",
"@types/promise-retry": "^1.1.3",
"@typescript-eslint/eslint-plugin": "^4.6.0",
"@typescript-eslint/parser": "^4.6.0",
"@vercel/ncc": "^0.24.1",
"eslint": "^7.12.1",
"eslint-config-prettier": "^6.15.0",
"eslint-config-xo": "^0.33.1",
"eslint-config-xo-typescript": "^0.35.0",
"eslint-import-resolver-typescript": "^2.3.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-sort-destructure-keys": "^1.3.5",
"eslint-plugin-typescript-sort-keys": "^1.5.0",
"eslint-plugin-unicorn": "^23.0.0",
"lodash": "^4.17.20",
"prettier": "^2.1.2",
"typescript": "^4.0.5"
"@trivago/prettier-plugin-sort-imports": "^4.2.0",
"@octokit/webhooks-types": "^7.1.0",
"@types/error-cause": "^1.0.1",
"@types/lodash-es": "^4.17.8",
"@types/node": "^20.4.5",
"@vercel/ncc": "^0.36.1",
"eslint-config-prettier": "^8.9.0",
"eslint-plugin-import": "^2.28.0",
"eslint-plugin-sort-destructure-keys": "^1.5.0",
"eslint-plugin-typescript-sort-keys": "^2.3.0",
"prettier": "^3.0.0",
"prettier-plugin-packagejson": "^2.4.5",
"typescript": "^5.1.6",
"xo": "^0.55.0",
"yarn-deduplicate": "^6.0.2"
}
}
5 changes: 0 additions & 5 deletions prettier.config.js

This file was deleted.

Loading