Skip to content

Version tag to 1.24.0-rc1 #2

Version tag to 1.24.0-rc1

Version tag to 1.24.0-rc1 #2

Workflow file for this run

name: Backport Pull Request
on:
pull_request_target:
types:
- closed
- opened
- reopened
branches:
- main
env:
GOLANG_VERSION: "1.22.x"
jobs:
# Label the source pull request with 'backport-requested' and all supported releases label, the goal is, by default
# we backport everything, except those PR that are created or contain `do not backport` explicitly.
label-source-pr:
name: Add labels to PR
if: |
github.event.pull_request.merged == false &&
!contains(github.event.pull_request.labels.*.name, 'backport-requested') &&
!contains(github.event.pull_request.labels.*.name, 'do not backport')
runs-on: ubuntu-22.04
steps:
-
name: Label the pull request
uses: actions-ecosystem/action-add-labels@v1
if: ${{ !contains(github.event.pull_request.labels.*.name, 'do not backport') }}
with:
github_token: ${{ secrets.REPO_GHA_PAT }}
number: ${{ github.event.pull_request.number }}
labels: |
backport-requested :arrow_backward:
release-1.22
release-1.23
-
name: Create comment
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body: |
:exclamation: By default, the pull request is configured to backport to all release branches.
- To stop backporting this pr, remove the label: backport-requested :arrow_backward: or add the label 'do not backport'
- To stop backporting this pr to a certain release branch, remove the specific branch label: release-x.y
reactions: heart
-
name: Remove redundant labels
uses: actions-ecosystem/action-remove-labels@v1
if: ${{ contains(github.event.pull_request.labels.*.name, 'do not backport') }}
with:
github_token: ${{ secrets.REPO_GHA_PAT }}
labels: |
backport-requested :arrow_backward:
release-1.22
release-1.23
## backport pull request in condition when pr contains 'backport-requested' label and contains target branches labels
back-porting-pr:
name: Backport to release branches
if: |
github.event.pull_request.merged == true &&
(
contains(github.event.pull_request.labels.*.name, 'backport-requested') ||
contains(github.event.pull_request.labels.*.name, 'backport-requested :arrow_backward:')
) &&
!contains(github.event.pull_request.labels.*.name, 'do not backport')
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
branch: [release-1.22, release-1.23]
env:
PR: ${{ github.event.pull_request.number }}
outputs:
commit: ${{ steps.check_commits.outputs.commit }}
steps:
-
name: Checkout code
if: contains( github.event.pull_request.labels.*.name, matrix.branch )
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ matrix.branch }}
token: ${{ secrets.REPO_GHA_PAT }}
-
name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GOLANG_VERSION }}
check-latest: true
-
name: Check commits
if: contains( github.event.pull_request.labels.*.name, matrix.branch )
id: check_commits
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
commit=$(gh pr view ${PR} --json mergeCommit -q ".mergeCommit.oid" 2>/dev/null || :)
if [ -z "${commit}" ]
then
echo "No commit found!"
exit 0
fi
echo "commit=${commit}" >> $GITHUB_OUTPUT
echo "cherry-pick commit ${commit} to branch ${{ matrix.branch }}"
author_name=$(git show -s --format='%an' "${commit}")
echo "AUTHOR_NAME=${author_name}" >> $GITHUB_ENV
author_email=$(git show -s --format='%ae' "${commit}")
echo "AUTHOR_EMAIL=${author_email}" >> $GITHUB_ENV
-
name: cherry pick
env:
COMMIT: ${{ steps.check_commits.outputs.commit }}
if: |
contains( github.event.pull_request.labels.*.name, matrix.branch ) && env.COMMIT != ''
run: |
git config user.email "${{ env.AUTHOR_EMAIL }}"
git config user.name "${{ env.AUTHOR_NAME }}"
git fetch
git cherry-pick -x --mainline 1 ${{ env.COMMIT }}
make fmt vet generate apidoc wordlist-ordered
if ! git diff --exit-code --quiet
then
echo "!!! Generated files need manually handling"
exit 1
fi
git push
create-tickets:
name: Create tickets for failures
needs:
- back-porting-pr
if: |
failure() && !cancelled() &&
needs.back-porting-pr.outputs.commit != ''
env:
PR: ${{ github.event.pull_request.number }}
COMMIT: ${{ needs.back-porting-pr.outputs.commit }}
runs-on: ubuntu-22.04
steps:
- name: create ticket
uses: dacbd/create-issue-action@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: Backport failure for pull request ${{ env.PR }}
labels: backport failure
body: |
### Context
Automatically backport failure for pull request ${{ env.PR }}
Pull request: ${{ github.server_url }}/${{ github.repository }}/pull/${{ env.PR }}
Commit: ${{ github.server_url }}/${{ github.repository }}/commit/${{ env.COMMIT }}
Workflow: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
To solve the ticket, open the workflow link above, and for each failed release branch check the following:
1. Whether the commit should be `cherry-pick`(ed) to this release branch, otherwise skip this release branch
2. If yes, `cherry-pick` the commit manually and push it to the release branch. You may need to resolve the
conflicts and issue `cherry-pick --continue` again. Also, a dependent commit missing may be causing the
failure, so if that's the case you may need to `cherry-pick` the dependent commit first.