Skip to content

Commit

Permalink
feat: CI action / label that makes it easy to cherry-pick just a comm…
Browse files Browse the repository at this point in the history
…it against cosmos SDK main (cosmos#12478)

## Description

Closes: [#268](osmosis-labs#268)

Adds a Github action that makes it easy to cherry pick commits from a fork PR to main under fork-cherry-pick.yml. The necessity for this PR arises from Mergify / GitHub marketplace currently not having tooling for this kind of action.

How it works:

- Cherry picks the commit of any fork of cosmos-sdk upon a merged PR to main on fork.
- Puts commit into a `pr-patch` branch; makes PR from pr-patch to cosmos:main

---

### Author Checklist

I have...

- [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [x] added `!` to the type prefix if API or client breaking change
- [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting))
- [x] provided a link to the relevant issue or specification
- [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/building-modules)
- [x] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing)
- [x] added a changelog entry to `CHANGELOG.md`
- [-] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [x] updated the relevant documentation or specification
- [x] reviewed "Files changed" and left comments if necessary
- [x] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed 
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
  • Loading branch information
xBalbinus authored Jul 27, 2022
1 parent 1ec4663 commit 9ffd57a
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/fork-cherry-pick.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
on:
#Set to trigger on every merge to main, not just a closed PR.
workflow_dispatch:
pull_request_target:
branches:
- main
types: ["closed"]

jobs:
cherry_pick:
runs-on: ubuntu-latest
name: Cherry pick into main
if: github.event.pull_request.merged == true
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Create PR Patch Branch
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "${GITHUB_ACTOR}" #Configs have to be set for pushing the cherry-picked changes onto fork pr-patch branch.
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git remote add upstream https://github.com/cosmos/cosmos-sdk.git
git fetch --all # Get the latest code
git checkout -b pr-patch upstream/main # Create new branch based on main branch
git cherry-pick ${{github.event.pull_request.head.sha}} # Cherry pick the latest commit of PR
git push -u origin pr-patch # Push your changes to the remote branch
- name: Autocreate PR
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
curl --request POST \
--url https://api.github.com/repos/cosmos/cosmos-sdk/pulls \
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
--header 'content-type: application/json' \
--data '{
"title": "Automated PR for commit: ${{github.event.pull_request.head.sha}}",
"body":"Please merge these awesome changes in!",
"head":"${{github.event.pull_request.user.login}}:pr-patch",
"base":"main"
}' \
--fail

0 comments on commit 9ffd57a

Please sign in to comment.