Skip to content

Commit

Permalink
Make backporting action use PRs to support protected branches [DOC-26…
Browse files Browse the repository at this point in the history
…8] (#1396)

In [DOC-255](https://hazelcast.atlassian.net/browse/DOC-255), branch
protection was added - preventing direct `push`es.

Instead, the backport workflow should create PRs to backport the
changes. This gives the _possibility_ for pre-merge checks to be run
(i.e. preventing introducing dead links etc).

Leverages [_existing_ `backport`
tool](https://github.com/hazelcast/backport), but exposed some issues
which need to be addressed **before this can be merged**:
- hazelcast/backport#14
- hazelcast/backport#15
- hazelcast/backport#16
- hazelcast/backport#17

Tested in a [test repo](https://github.com/JackPGreen2/hz-docs), where a
[dummy PR](JackPGreen2#5) was
[successfully
backported](JackPGreen2#16). However,
due to the complexity of fork-triggering, it wil need to be re-tested
once merged.

Fixes: [DOC-268](https://hazelcast.atlassian.net/browse/DOC-268)

[DOC-255]:
https://hazelcast.atlassian.net/browse/DOC-255?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
[DOC-268]:
https://hazelcast.atlassian.net/browse/DOC-268?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
  • Loading branch information
JackPGreen authored Dec 2, 2024
1 parent ed6736e commit 3f627f4
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions .github/workflows/backport-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,20 @@ jobs:
labels: ${{ inputs.label-to-check-for }}

- name: See result
if: runner.debug == '1'
run: echo "${{ steps.check_pr_labels.outputs.result }}"

- name: Checkout repository
if: ${{ steps.check_pr_labels.outputs.result == 'true' }}
uses: actions/checkout@v4
with:
# ensure the backport target branch is checked out, too
fetch-depth: 0

- name: Checkout maintenance branch and cherry-pick
if: ${{ steps.check_pr_labels.outputs.result == 'true' }}
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git fetch
git checkout ${{ inputs.target-branch }}
git cherry-pick -x --strategy=recursive -X theirs $GITHUB_SHA
git push
- if: ${{ steps.check_pr_labels.outputs.result == 'true' }}
uses: hazelcast/backport/.github/actions/backport@main
with:
GITHUB_TOKEN: ${{ github.token }}
TARGET_BRANCH: ${{ inputs.target-branch }}
REF_TO_BACKPORT: ${{ github.sha }}
BACKPORT_OPTIONS: --omit-labels

0 comments on commit 3f627f4

Please sign in to comment.