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

Backport: disable no-squash with backport-squash label #1430

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions .github/workflows/backport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,40 @@ on:

env:
GITHUB_TOKEN: ${{ secrets.BACKPORT_TOKEN }}
NO_SQUASH_OPTION: true

jobs:
backporting:
name: "Backporting"
concurrency:
group: backporting-${{ github.head_ref }}
cancel-in-progress: true
# 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'
&& contains(github.event.pull_request.labels.*.name, 'backport')
&& (contains(github.event.pull_request.labels.*.name, 'backport')
|| contains(github.event.pull_request.labels.*.name, 'backport-squash'))
|| (
github.event.action == 'labeled'
&& contains(github.event.label.name, 'backport')
)
)
runs-on: ubuntu-latest
steps:
- name: Override no-squash option
if: >
(github.event.action == 'closed' && contains(github.event.pull_request.labels.*.name, 'backport-squash'))
|| (github.event.action == 'labeled' && contains(github.event.label.name, 'backport-squash'))
shell: bash
run: |
echo "NO_SQUASH_OPTION=false" >> $GITHUB_ENV
- name: Backporting
uses: kiegroup/[email protected]
with:
target-branch: 0.12.x
pull-request: ${{ github.event.pull_request.url }}
auth: ${{ secrets.BACKPORT_TOKEN }}
no-squash: true
no-squash: ${{ env.NO_SQUASH_OPTION }}
12 changes: 11 additions & 1 deletion docs/RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,17 @@ docker logout quay.io

Backports are automatically created from PRs against the master branch to the stable branch.

To backport a change, add the `backport` label to the PR that you opened against the master branch.
To backport a change, add the `backport` (or `backport-squash` but not both) label to the PR that you opened against the master branch.
johnaohara marked this conversation as resolved.
Show resolved Hide resolved

Which label should I use?
* `backport`: (default) this uses the `no-squash=true` option so that the tool tries to backport all commits coming
from the original pull request you are trying to backport.
> _**Note**_ that in this case the commit SHAs should exist during the backporting, i.e,
delete the source branch only after the backporting PR got created.
* `backport-squash`: with this label you set `no-squash=false` option, so that the tool tries to backport the pull request
`merge_commit_sha`.
> _**Note**_ the value of the `merge_commit_sha` attribute changes depending on the state of the pull request, see [Github doc](https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#get-a-pull-request)
for more details.

After the PR is merged, the backport PR will be automatically created.

Expand Down