backup: 2025-05-28 21:12:11 #51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Cherry-pick to main on any branch push | |
| on: | |
| push: | |
| branches: ["**"] | |
| jobs: | |
| cherry-pick: | |
| if: github.ref != 'refs/heads/main' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.PAT_TOKEN }} | |
| - name: Set up Git user | |
| run: | | |
| git config user.name "y4zdev" | |
| git config user.email "[email protected]" | |
| - name: Get pushed branch name | |
| id: vars | |
| run: echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV | |
| - name: Fetch all branches | |
| run: git fetch origin main | |
| - name: Switch to main | |
| run: git checkout main | |
| - name: Cherry-pick commits from pushed branch | |
| run: | | |
| echo "COMMIT_HASH=$(git rev-parse origin/${BRANCH_NAME})" >> $GITHUB_ENV | |
| - name: Cherry-pick commit to main with theirs strategy | |
| run: | | |
| git cherry-pick --strategy=recursive -X theirs $COMMIT_HASH | |
| - name: Push changes to main | |
| run: git push https://x-access-token:${{ secrets.PAT_TOKEN }}@github.com/${{ github.repository }} main |