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

Make backporting action use PRs to support protected branches [DOC-268] #1396

Merged
merged 5 commits into from
Dec 2, 2024
Merged
Changes from 1 commit
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
37 changes: 33 additions & 4 deletions .github/workflows/backport-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ jobs:
runs-on: ubuntu-latest
nishaatr marked this conversation as resolved.
Show resolved Hide resolved

steps:
- name: Print accessible environment variables
JackPGreen marked this conversation as resolved.
Show resolved Hide resolved
if: runner.debug == '1'
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: |
echo "${GITHUB_CONTEXT}"
printenv

- name: Check PR for backport label
id: check_pr_labels
uses: shioyang/[email protected]
Expand All @@ -29,15 +37,36 @@ jobs:
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
path: repo

- name: Checkout Backport tool
if: ${{ steps.check_pr_labels.outputs.result == 'true' }}
uses: actions/checkout@v4
with:
repository: hazelcast/backport
path: backport
nishaatr marked this conversation as resolved.
Show resolved Hide resolved

- name: Checkout maintenance branch and cherry-pick
if: ${{ steps.check_pr_labels.outputs.result == 'true' }}
working-directory: repo
run: |
# Git metadata is required but not available out-of-the-box, inherit from the action
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
# Add "upstream" remote as checkout action doesn't include by default
git remote add upstream "${{ github.event.repository.clone_url }}"
nishaatr marked this conversation as resolved.
Show resolved Hide resolved
git fetch --all

backport_target_branch=upstream/"${{ inputs.target-branch }}"
echo "::debug::Running backport script to backport "${GITHUB_SHA}" into \"${backport_target_branch}\""

${GITHUB_WORKSPACE}/backport/backport \
"${GITHUB_SHA}" \
"${backport_target_branch}" \
--non-interactive \
--omit-labels
env:
GH_TOKEN: ${{ github.token }}