github.com/cosmos/cosmos-sdk@v0.50.10/.github/workflows/fork-cherry-pick.yml (about)

     1  # This CI is disabled on main and meant to be enabled on forks as an easy way to cherry pick fork commits into main.
     2  # In order to submit a PR from your repo to the Cosmos SDK, a PRBOT_PAT secret (personal access token) must be available for the GitHub Action (Settings > Secrets > Actions).
     3  # The PR will be submitted from the user of the PAT. Note, the PRBOT_PAT user must have write access to the repo.
     4  name: Cherry pick PR to Cosmos SDK
     5  on:
     6    # Set to trigger on every merge to main, not just a closed PR.
     7    workflow_dispatch:
     8    pull_request_target:
     9      branches:
    10        - main
    11      types: ["closed"]
    12  
    13  jobs:
    14    cherry_pick:
    15      permissions: write-all
    16      runs-on: ubuntu-latest
    17      name: Cherry pick into main
    18      if: github.event.pull_request.merged == true
    19      steps:
    20        - name: Checkout
    21          uses: actions/checkout@v3
    22        - name: Create PR Patch Branch
    23          shell: bash
    24          env:
    25            PR_NAME: pr-patch-${{ github.sha }}
    26          run: |
    27            git config --global user.name "${{ github.actor }}" # Config have to be set for pushing the cherry-picked changes onto fork pr-patch branch.
    28            git config --global user.email "${{ github.actor }}@users.noreply.github.com"
    29            git remote add upstream https://github.com/cosmos/cosmos-sdk.git
    30            git fetch --all  # Get the latest code
    31            git checkout -b $PR_NAME upstream/main    # Create new branch based on main branch
    32            git cherry-pick -X theirs ${{ github.sha }} # Cherry pick the latest commit of PR
    33            git push -u origin $PR_NAME # Push your changes to the remote branch
    34        - name: Autocreate PR
    35          shell: bash
    36          env:
    37            GH_TOKEN: ${{ secrets.PRBOT_PAT }}
    38          run: |
    39            gh pr create --repo cosmos/cosmos-sdk --base main --head "${{ github.event.repository.owner.login }}:pr-patch-${{ github.sha }}" --title "${{ github.event.pull_request.title }}" --body "Automated PR for commit: ${{ github.sha }} from ${{ github.repository }}"