{"id":17218267,"url":"https://github.com/korthout/backport-action","last_synced_at":"2025-05-15T14:08:49.077Z","repository":{"id":36968639,"uuid":"312027768","full_name":"korthout/backport-action","owner":"korthout","description":"Fast and flexible GitHub action to cherry-pick merged pull requests to selected branches","archived":false,"fork":false,"pushed_at":"2025-05-02T06:42:57.000Z","size":5813,"stargazers_count":77,"open_issues_count":19,"forks_count":29,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-05-05T19:52:40.952Z","etag":null,"topics":["backport","bors","cherry-pick","forwardport","github-action","merge-queue","patch","pull-requests"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/korthout.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-11-11T16:32:06.000Z","updated_at":"2025-03-28T16:59:46.000Z","dependencies_parsed_at":"2023-02-12T03:30:41.526Z","dependency_job_id":"fe09da49-4239-4a91-9a34-61ae47fa4872","html_url":"https://github.com/korthout/backport-action","commit_stats":{"total_commits":540,"total_committers":18,"mean_commits":30.0,"dds":0.4092592592592592,"last_synced_commit":"e8ba02342f095377d8f870abfac2da22ce7205c1"},"previous_names":[],"tags_count":51,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/korthout%2Fbackport-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/korthout%2Fbackport-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/korthout%2Fbackport-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/korthout%2Fbackport-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/korthout","download_url":"https://codeload.github.com/korthout/backport-action/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254355335,"owners_count":22057354,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backport","bors","cherry-pick","forwardport","github-action","merge-queue","patch","pull-requests"],"created_at":"2024-10-15T03:45:57.213Z","updated_at":"2025-05-15T14:08:44.034Z","avatar_url":"https://github.com/korthout.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Backport action\n\nFast and flexible GitHub action to backport merged pull requests to selected branches.\n\nThis can be useful when you're supporting multiple versions of your product.\nAfter fixing a bug, you may want to apply that patch to the other versions.\nThe manual labor of cherry-picking the individual commits can be automated using this action.\n\n## Features\n\n- Works out of the box - No configuration required / Defaults for everything\n- Fast - Only fetches the bare minimum / Supports shallow clones\n- Flexible - Supports all [merge methods](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/about-merge-methods-on-github) including [merge queue](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/managing-a-merge-queue) and [Bors](https://bors.tech/)\n- Configurable - Use inputs and outputs to fit it to your project\n- Transparent - Informs about its success / Cherry-picks with [`-x`](https://git-scm.com/docs/git-cherry-pick#Documentation/git-cherry-pick.txt--x)\n\n## How it works\n\nYou can select the branches to backport merged pull requests in two ways:\n- using labels on the merged pull request.\n  The action looks for labels on your merged pull request matching the [`label_pattern`](#label_pattern) input\n- using the [`target_branches`](#target_branches) input\n\nFor each selected branch, the backport action takes the following steps:\n1. fetch and checkout a new branch from the target branch\n2. cherry-pick commits containing the merged pull request's changes, using the [`cherry_picking`](#cherry_picking) input\n3. create a pull request to merge the new branch into the target branch\n4. comment on the original pull request about its success\n\nThe commits are cherry-picked with the [`-x`](https://git-scm.com/docs/git-cherry-pick#Documentation/git-cherry-pick.txt--x) flag.\n\n## Usage\n\nAdd the following workflow configuration to your repository's `.github/workflows` folder.\n\n```yaml\nname: Backport merged pull request\non:\n  pull_request_target:\n    types: [closed]\npermissions:\n  contents: write # so it can comment\n  pull-requests: write # so it can create pull requests\njobs:\n  backport:\n    name: Backport pull request\n    runs-on: ubuntu-latest\n    # Don't run on closed unmerged pull requests\n    if: github.event.pull_request.merged\n    steps:\n      - uses: actions/checkout@v4\n      - name: Create backport pull requests\n        uses: korthout/backport-action@v3\n```\n\n\u003e **Note**\n\u003e This workflow runs on [`pull_request_target`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target) so that `GITHUB_TOKEN` has write access to the repo when the merged pull request comes from a forked repository.\n\u003e This write access is necessary for the action to push the commits it cherry-picked.\n\n### Trigger using a comment\n\nYou can also trigger the backport action by writing a comment containing `/backport` on a merged pull request.\nTo enable this, add the following workflow configuration to your repository's `.github/workflows` folder.\n\n\u003cdetails\u003e\u003csummary\u003eTrigger backport action using a comment\u003c/summary\u003e\n \u003cp\u003e\n\n```yaml\nname: Backport merged pull request\non:\n  pull_request_target:\n    types: [closed]\n  issue_comment:\n    types: [created]\npermissions:\n  contents: write # so it can comment\n  pull-requests: write # so it can create pull requests\njobs:\n  backport:\n    name: Backport pull request\n    runs-on: ubuntu-latest\n\n    # Only run when pull request is merged\n    # or when a comment starting with `/backport` is created by someone other than the\n    # https://github.com/backport-action bot user (user id: 97796249). Note that if you use your\n    # own PAT as `github_token`, that you should replace this id with yours.\n    if: \u003e\n      (\n        github.event_name == 'pull_request_target' \u0026\u0026\n        github.event.pull_request.merged\n      ) || (\n        github.event_name == 'issue_comment' \u0026\u0026\n        github.event.issue.pull_request \u0026\u0026\n        github.event.comment.user.id != 97796249 \u0026\u0026\n        startsWith(github.event.comment.body, '/backport')\n      )\n    steps:\n      - uses: actions/checkout@v4\n      - name: Create backport pull requests\n        uses: korthout/backport-action@v3\n```\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n## Inputs\n\nThe action can be configured with the following optional [inputs](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepswith):\n\n### `add_author_as_assignee`\n\nDefault: `false` (disabled)\n\nControls whether to set the author of the original pull request as an assignee on the backport pull request.\nBy default, the original author is not made an assignee.\n\n### `add_labels`\n\nDefault: `''` (disabled)\n\nThe action will add these labels (comma-delimited) to the backport pull request.\nBy default, no labels are added.\n\n### `branch_name`\n\nDefault: `backport-${pull_number}-to-${target_branch}`\n\nTemplate used as the name for branches created by this action. \n\nPlaceholders can be used to define variable values.\nThese are indicated by a dollar sign and curly braces (`${placeholder}`).\nPlease refer to this action's README for all available [placeholders](#placeholders).\n\n### `cherry_picking`\n\nDefault: `auto`\n\nDetermines which commits are cherry-picked.\n\nWhen set to `auto`, the action cherry-picks the commits based on the method used to merge the pull request.\n- For \"Squash and merge\", the action cherry-picks the squashed commit.\n- For \"Rebase and merge\", the action cherry-picks the rebased commits.\n- For \"Merged as a merge commit\", the action cherry-picks the commits from the pull request.\n\nWhen set to `pull_request_head`, the action cherry-picks the commits from the pull request.\nSpecifically, those reachable from the pull request's head and not reachable from the pull request's base.\n\nBy default, the action cherry-picks the commits based on the method used to merge the pull request.\n\n### `copy_assignees`\n\nDefault: `false` (disabled)\n\nControls whether to copy the assignees from the original pull request to the backport pull request.\nBy default, the assignees are not copied.\n\n### `copy_labels_pattern`\n\nDefault: `''` (disabled)\n\nRegex pattern to match github labels which will be copied from the original pull request to the backport pull request.\nNote that labels matching `label_pattern` are excluded.\nBy default, no labels are copied.\n\n### `copy_milestone`\n\nDefault: `false` (disabled)\n\nControls whether to copy the milestone from the original pull request to the backport pull request.\nBy default, the milestone is not copied.\n\n### `copy_requested_reviewers`\n\nDefault: `false` (disabled)\n\nControls whether to copy the requested reviewers from the original pull request to the backport pull request.\nNote that this does not request reviews from those users who already reviewed the original pull request.\nBy default, the requested reviewers are not copied.\n\n### `experimental`\n\nDefault:\n\n```json\n{\n  \"detect_merge_method\": false\n}\n```\n\nConfigure experimental features by passing a JSON object.\nThe following properties can be specified:\n\n#### `conflict_resolution`\n\nDefault: `fail`\n\nSpecifies how the action will handle a conflict occuring during the cherry-pick. \nIn all cases, the action will stop the cherry-pick at the first conflict encountered.\n\nBehavior is defined by the option selected.\n- When set to `fail` the backport fails when the cherry-pick encounters a conflict.\n- When set to `draft_commit_conflicts` the backport will always create a draft pull request with the first conflict encountered committed.\n\nInstructions are provided on the original pull request on how to resolve the conflict and continue the cherry-pick.\n\n#### `downstream_repo`\n\nDefine if you want to backport to a repository other than where the workflow runs.\n\nBy default, the action always backports to the repository in which the workflow runs.\n\n#### `downstream_owner`\n\nDefine if you want to backport to another owner than the owner of the repository the workflow runs on.\nOnly takes effect if the `downstream_repo` property is also defined.\n\nBy default, uses the owner of the repository in which the workflow runs.\n\n### `github_token`\n\nDefault: `${{ github.token }}`\n\nToken to authenticate requests to GitHub.\nUsed to create and label pull requests and to comment.\n\nEither `GITHUB_TOKEN` or a repo-scoped [Personal Access Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) (PAT).\n\n### `github_workspace`\n\nDefault: `${{ github.workspace }}`\n\nWorking directory for the backport action.\n\n### `label_pattern`\n\nDefault: `^backport ([^ ]+)$` (e.g. matches `backport release-3.4`)\n\nRegex pattern to match the backport labels on the merged pull request.\nMust contain a capture group for the target branch.\nLabel matching can be disabled entirely using an empty string `''` as pattern.\n\nThe action will backport the pull request to each matched target branch.\nNote that the pull request's headref is excluded automatically.\nSee [How it works](#how-it-works).\n\n### `merge_commits`\n\nDefault: `fail`\n\nSpecifies how the action should deal with merge commits on the merged pull request.\n\n- When set to `fail` the backport fails when the action detects one or more merge commits.\n- When set to `skip` the action only cherry-picks non-merge commits, i.e. it ignores merge commits.\n  This can be useful when you [keep your pull requests in sync with the base branch using merge commits](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/keeping-your-pull-request-in-sync-with-the-base-branch).\n\n### `pull_description`\n\nDefault:\n```\n# Description\nBackport of #${pull_number} to `${target_branch}`.\n```\n\nTemplate used as description (i.e. body) in the pull requests created by this action.\n\nPlaceholders can be used to define variable values.\nThese are indicated by a dollar sign and curly braces (`${placeholder}`).\nPlease refer to this action's README for all available [placeholders](#placeholders).\n\n### `pull_title`\n\nDefault: `[Backport ${target_branch}] ${pull_title}`\n\nTemplate used as the title in the pull requests created by this action.\n\nPlaceholders can be used to define variable values.\nThese are indicated by a dollar sign and curly braces (`${placeholder}`).\nPlease refer to this action's README for all available [placeholders](#placeholders).\n\n### `source_pr_number`\n\nDefault: `''` (not set)\n\nSpecifies the pull request (by its number) to backport, i.e. the source pull request.\nWhen set, the action will backport the specified pull request to each target branch.\nWhen not set, the action determines the source pull request from the event payload.\n\n### `target_branches`\n\nDefault: `''` (disabled)\n\nThe action will backport the pull request to each specified target branch (space-delimited).\nNote that the pull request's headref is excluded automatically.\nSee [How it works](#how-it-works).\n\nCan be used in addition to backport labels.\nBy default, only backport labels are used to specify the target branches.\n\n## Placeholders\nIn the `pull_description` and `pull_title` inputs, placeholders can be used to define variable values.\nThese are indicated by a dollar sign and curly braces (`${placeholder}`).\nThe following placeholders are available and are replaced with:\n\nPlaceholder | Replaced with\n------------|------------\n`issue_refs` | GitHub issue references to all issues mentioned in the original pull request description seperated by a space, e.g. `#123 #456 korthout/backport-action#789`\n`pull_author` | The username of the original pull request's author, e.g. `korthout`\n`pull_description`| The description (i.e. body) of the original pull request that is backported, e.g. `Summary: This patch was created to..`\n`pull_number` | The number of the original pull request that is backported, e.g. `123`\n`pull_title` | The title of the original pull request that is backported, e.g. `fix: some error`\n`target_branch`| The branchname to which the pull request is backported, e.g. `release-0.23`\n\n## Outputs\n\nThe action provides the following [outputs](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idoutputs):\n\nOutput | Description\n-------|------------\n`created_pull_numbers` | Space-separated list containing the identifying number of each created pull request. Or empty when the action created no pull requests. For example, `123` or `123 124 125`.\n`was_successful` | Whether or not the changes could be backported successfully to all targets. Either `true` or `false`.\n`was_successful_by_target` | Whether or not the changes could be backported successfully to all targets - broken down by target. Follows the pattern `{{label}}=true\\|false`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkorthout%2Fbackport-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkorthout%2Fbackport-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkorthout%2Fbackport-action/lists"}