Skip to content

Commit

Permalink
ci: Make it possible to backport multiple commits (#3193)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaminyam authored Dec 9, 2024
1 parent a6d0e49 commit 3968538
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions .github/workflows/backport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,24 @@ on:
- 'main'

jobs:
backport-commits:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.commits.outputs.commits }}
steps:
- name: Get all commits in the push event
id: commits
run: |
commits_json=$(echo '${{ toJSON(github.event.commits) }}' | jq -c '[.[].id]')
echo "commits=${commits_json}" >> $GITHUB_OUTPUT
backport-target-branch:
runs-on: ubuntu-latest
needs: backport-commits
strategy:
matrix:
commits: ${{ fromJson(needs.backport-commits.outputs.matrix) }}
outputs:
matrix: ${{ steps.milestones.outputs.matrix }}
latest_commit: ${{ steps.commit.outputs.latest_commit }}
Expand All @@ -22,6 +38,7 @@ jobs:
uses: actions/checkout@v4
with:
lfs: false
ref: ${{ matrix.commits }}
- name: Extract pr_number from commit message
id: commit
run: |
Expand Down Expand Up @@ -78,7 +95,7 @@ jobs:
break
fi
done
matrix=$(jq -nc '{include: $ARGS.positional | map_values({milestone: .})}' --args "${target_milestones[@]}")
matrix=$(jq -nc --argjson milestones "$(printf '%s\n' "${target_milestones[@]}" | jq -R . | jq -s .)" '$milestones')
echo "matrix=$matrix" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ github.token }}
Expand All @@ -88,7 +105,8 @@ jobs:
runs-on: ubuntu-latest
needs: backport-target-branch
strategy:
matrix: ${{ fromJson(needs.backport-target-branch.outputs.matrix) }}
matrix:
milestone: ${{ fromJson(needs.backport-target-branch.outputs.matrix) }}
permissions:
pull-requests: write
steps:
Expand Down

0 comments on commit 3968538

Please sign in to comment.