From 9028c172481d91f544106ed47192684fb05cb423 Mon Sep 17 00:00:00 2001 From: Yuhong Sun Date: Thu, 24 Oct 2024 18:50:20 -0700 Subject: [PATCH] k --- .github/pull_request_template.md | 30 ++++++----- .github/workflows/pr-backport-autotrigger.yml | 52 +++++++++++++++++++ 2 files changed, 69 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/pr-backport-autotrigger.yml diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index e57283f0377..c49908b1d54 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -6,20 +6,24 @@ [Describe the tests you ran to verify your changes] -## Accepted Risk -[Any know risks or failure modes to point out to reviewers] +## Accepted Risk (provide if relevant) +N/A -## Related Issue(s) -[If applicable, link to the issue(s) this PR addresses] +## Related Issue(s) (provide if relevant) +N/A -## Checklist: -- [ ] All of the automated tests pass -- [ ] All PR comments are addressed and marked resolved -- [ ] If there are migrations, they have been rebased to latest main -- [ ] If there are new dependencies, they are added to the requirements -- [ ] If there are new environment variables, they are added to all of the deployment methods -- [ ] If there are new APIs that don't require auth, they are added to PUBLIC_ENDPOINT_SPECS -- [ ] Docker images build and basic functionalities work -- [ ] Author has done a final read through of the PR right before merge +## Mental Checklist: +- All of the automated tests pass +- All PR comments are addressed and marked resolved +- If there are migrations, they have been rebased to latest main +- If there are new dependencies, they are added to the requirements +- If there are new environment variables, they are added to all of the deployment methods +- If there are new APIs that don't require auth, they are added to PUBLIC_ENDPOINT_SPECS +- Docker images build and basic functionalities work +- Author has done a final read through of the PR right before merge + +## Backporting (check the box to trigger backport action) +Note: You have to check that the action passes, otherwise resolve the conflicts manually and tag the patches. +[ ] This PR should be backported (make sure to check that the backport attempt succeeds) diff --git a/.github/workflows/pr-backport-autotrigger.yml b/.github/workflows/pr-backport-autotrigger.yml new file mode 100644 index 00000000000..4ba5136a82c --- /dev/null +++ b/.github/workflows/pr-backport-autotrigger.yml @@ -0,0 +1,52 @@ +name: Backport on Merge + +on: + pull_request: + types: [closed] + +jobs: + backport: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Check for Backport Checkbox + id: checkbox-check + run: | + PR_BODY="${{ github.event.pull_request.body }}" + if [[ "$PR_BODY" == *"[x] This PR should be backported"* ]]; then + echo "::set-output name=backport::true" + else + echo "::set-output name=backport::false" + fi + + - name: List and sort release branches + id: list-branches + run: | + git fetch --all + BRANCHES=$(git branch -r | grep 'origin/release/v' | sed 's|origin/release/v||' | sort -Vr) + BETA=$(echo "$BRANCHES" | head -n 1) + STABLE=$(echo "$BRANCHES" | head -n 2 | tail -n 1) + echo "::set-output name=beta::$BETA" + echo "::set-output name=stable::$STABLE" + + - name: Trigger Backport + if: steps.checkbox-check.outputs.backport == 'true' + run: | + echo "Backporting to beta ${{ steps.list-branches.outputs.beta }} and stable ${{ steps.list-branches.outputs.stable }}" + # Fetch all history for all branches and tags + git fetch --prune --unshallow + # Checkout the beta branch + git checkout ${{ steps.list-branches.outputs.beta }} + # Cherry-pick the last commit from the merged PR + git cherry-pick ${{ github.event.pull_request.merge_commit_sha }} + # Push the changes to the beta branch + git push origin ${{ steps.list-branches.outputs.beta }} + # Checkout the stable branch + git checkout ${{ steps.list-branches.outputs.stable }} + # Cherry-pick the last commit from the merged PR + git cherry-pick ${{ github.event.pull_request.merge_commit_sha }} + # Push the changes to the stable branch + git push origin ${{ steps.list-branches.outputs.stable }}