|
| 1 | +name: Backport to older releases |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - master |
| 6 | + |
| 7 | +jobs: |
| 8 | + |
| 9 | + backport: |
| 10 | + strategy: |
| 11 | + fail-fast: false |
| 12 | + matrix: |
| 13 | + branch: [ 'release-0.28', 'release-0.27' ] |
| 14 | + name: Backport change to branch ${{ matrix.branch }} |
| 15 | + |
| 16 | + runs-on: ubuntu-20.04 |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Check out code |
| 20 | + uses: actions/checkout@v1 |
| 21 | + with: |
| 22 | + fetch-depth: 0 |
| 23 | + - name: Create a cherry-pick PR |
| 24 | + run: | |
| 25 | + if ! git diff --quiet HEAD^ HEAD -- vendor/libgit2; then |
| 26 | + echo '::warning::Skipping cherry-pick since it is a vendored libgit2 bump' |
| 27 | + exit 0 |
| 28 | + fi |
| 29 | +
|
| 30 | + BRANCH_NAME="cherry-pick-${{ github.run_id }}-${{ matrix.branch }}" |
| 31 | +
|
| 32 | + # Setup usernames and authentication |
| 33 | + git config --global user.name "${{ github.actor }}" |
| 34 | + git config --global user.email "${{ github.actor }}@users.noreply.github.com" |
| 35 | + cat <<- EOF > $HOME/.netrc |
| 36 | + machine github.com |
| 37 | + login ${{ github.actor }} |
| 38 | + password ${{ secrets.GITHUB_TOKEN }} |
| 39 | + machine api.github.com |
| 40 | + login ${{ github.actor }} |
| 41 | + password ${{ secrets.GITHUB_TOKEN }} |
| 42 | + EOF |
| 43 | + chmod 600 $HOME/.netrc |
| 44 | +
|
| 45 | + # Create the cherry-pick commit and create the PR for it. |
| 46 | + git checkout "${{ matrix.branch }}" |
| 47 | + git switch -c "${BRANCH_NAME}" |
| 48 | + git cherry-pick -x "${{ github.sha }}" |
| 49 | + git push --set-upstream origin "${BRANCH_NAME}" |
| 50 | + GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}" gh pr create \ |
| 51 | + --base "${{ matrix.branch }}" \ |
| 52 | + --title "$(git --no-pager show --format="%s" --no-patch HEAD)" \ |
| 53 | + --body "$(git --no-pager show --format="%b" --no-patch HEAD)" |
0 commit comments