Skip to content

cherry pick to chosen branch #7678

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
37 changes: 28 additions & 9 deletions .github/workflows/cherry-pick.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: "Cherry-pick dependencies to release branch"
on:
pull_request:
branches:
- main
types: ["closed"]
issue_comment:
types:
- created

permissions:
contents: read
Expand All @@ -15,23 +14,43 @@ jobs:
pull-requests: write
runs-on: ubuntu-22.04
name: Cherry pick into release branch
if: ${{ (contains(github.event.pull_request.labels.*.name, 'dependencies') || contains(github.event.pull_request.labels.*.name, 'needs cherry pick')) && github.event.pull_request.merged == true }}
if: ${{ github.event.issue.pull_request.merged_at != null }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
token: ${{ secrets.NGINX_PAT }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the reason for the NGINX_PAT usage, to allow automatic triggering of downstream actions?
If we cannot use a GITHUB_TOKEN, we'll need to make sure the NGINX_PAT is available in the docs.


- name: Check if Actor is a Member of one of the teams
uses: im-open/[email protected]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should pin this to a specific commit so dependabot got pickup the updates

with:
github-actor: ${{ github.actor }}
github-organization: ${{ github.repository_owner}}
github-team-slugs: |
[
"nic",
"nginx-docs"
]
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Set release branch variable
id: branch
env:
comment_body: ${{ github.event.comment.body }}
run: |
branch=$(git branch -a | egrep '^\s+remotes/origin/release' | awk '{print $1}' | sort -u | tail -n 1)
release_branch=$(basename ${branch})
echo "branch=${release_branch}" >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
regex="/cherry-pick to (release-[2-9]+\.[0-9]+)"
if [[ "${comment_body}" =~ $regex ]]; then
branch=${BASH_REMATCH[1]}
if git branch -a | egrep '^\s+remotes/origin/release' | grep -q "${branch}"; then
echo "branch=${branch}" >> $GITHUB_OUTPUT
else
echo "branch=" >> $GITHUB_OUTPUT
fi
fi

- name: Cherry pick into ${{ steps.branch.outputs.branch }}
if: ${{ steps.branch.outputs.branch }}
uses: carloscastrojumo/github-cherry-pick-action@503773289f4a459069c832dc628826685b75b4b3 # v1.0.10
with:
branch: ${{ steps.branch.outputs.branch }}
Expand Down