Skip to content

Commit 738713a

Browse files
javorszkyCopilot
andauthored
adds developer documentation on github comment workflows (#10508)
* adds developer documentation on github comment workflows * Add footnote to cherry-pic docs * Cherry-pick runs on PRs * Apply suggestions from code review Tiny fixes copilot found Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Gabor Javorszky <gabor@javorszky.co.uk> * Clarify cherry-pick run condition * Clarify git cherry-pick flags Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Gabor Javorszky <gabor@javorszky.co.uk> * Reword cherry pick base and strategy Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Gabor Javorszky <gabor@javorszky.co.uk> * Remove a trailing whitespace Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Gabor Javorszky <gabor@javorszky.co.uk> * Further clarify nit for cherry pick strategy Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Gabor Javorszky <gabor@javorszky.co.uk> * Another nit by copilot on wording Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Gabor Javorszky <gabor@javorszky.co.uk> --------- Signed-off-by: Gabor Javorszky <gabor@javorszky.co.uk> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 69349c7 commit 738713a

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# GitHub comment commands available
2+
3+
## `/cherry-pick to <branch>`
4+
5+
Functionality is in the [cherry-pick.yml](../../.github/workflows/cherry-pick.yml) file.
6+
7+
### What it does
8+
9+
1. saves the target branch per the comment
10+
2. figures out the merged PR's prefix (`chore/`, `fix/`, `ci/` [^1])
11+
3. creates a new cherry pick branch named `<prefix>/cherry-pick-<target branch>-<sha>` on top of the `<target branch>` from the comment
12+
4. decides on a merge strategy based on the merge commit and the PR's original base branch
13+
1. [-m 1](https://git-scm.com/docs/git-cherry-pick#Documentation/git-cherry-pick.txt--mparent-number): `git cherry-pick -x -m 1 <merge sha>` for merge commits (2+ parents)
14+
2. [-x](https://git-scm.com/docs/git-cherry-pick#Documentation/git-cherry-pick.txt--x): `git cherry-pick -x <merge sha>` for squash merges (or single-commit rebases) (merge commit has 1 parent on base)
15+
3. [-x](https://git-scm.com/docs/git-cherry-pick#Documentation/git-cherry-pick.txt--x): `git cherry-pick -x <merge sha>~<# of commits>..<merge sha>` for rebases (range cherry-pick)
16+
5. (force) pushes the cherry-pick branch
17+
6. creates a new PR from the cherry-pick branch against the target in the comment
18+
19+
[^1]: it only checks [a-z], so `new-feature/other-branch-name` would NOT get `new-feature`, because `-` is not in the regex
20+
21+
### When it fires
22+
23+
All of these need to be true:
24+
25+
* on new issue comments
26+
* if the repository is `nginx/kubernetes-ingress` (so forks and mirrors do not fire)
27+
* that are Pull Requests (PRs are also issue comments per the GitHub API with an extra flag)
28+
* where the person making the comment is either a repository member or owner
29+
* the comment body contains `/cherry-pick to`
30+
* that's followed by either `release-x.y` or `release-20YY-lts` [(technically a regex, but the point is that it needs to be one of the release branches)](../../.github/workflows/cherry-pick.yml#L62), and the user is in the `CHERRY_PICK_USERS` repository variable
31+
32+
## `/approve-pipeline-run`
33+
34+
Functionality is in the [external-pr.yml](../../.github/workflows/external-pr.yml) file.
35+
36+
### What it does
37+
38+
1. Checks out the branch of the PR from the fork
39+
2. adds the NIC repository as an upstream
40+
3. creates a new branch named `chore/<original-branch-name>-<short-sha>-do-not-merge`
41+
4. pushes that branch onto our repository in GitHub
42+
5. creates a PR in the NIC repository
43+
1. with the title `DO NOT MERGE <original PR title>`
44+
2. with the original body content
45+
3. as a draft PR
46+
47+
### When it fires
48+
49+
All of these need to be true:
50+
51+
* on new PR comments (GitHub `issue_comment` event, `created` type)
52+
* that are Pull Requests
53+
* where the PR is opened from a forked repository (the internal mirror job only runs when `is_fork == 'true'`)
54+
* where the target repository is `nginx/kubernetes-ingress` (so PRs against forks and mirrors do not fire)
55+
* and the comment body is exactly `/approve-pipeline-run`
56+
* and the commenter has `admin`, `write`, or `maintain` permission on the repository

0 commit comments

Comments
 (0)