Skip to content

Commit

Permalink
ci: Fix matrix variable to use target_branches (#3274)
Browse files Browse the repository at this point in the history
Co-authored-by: Joongi Kim <[email protected]>
  • Loading branch information
Yaminyam and achimnol committed Dec 20, 2024
1 parent b35bac4 commit f917ded
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/backport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ jobs:
steps:
- name: Get all commits in the push event
id: commits
env:
COMMITS: ${{ toJson(github.event.commits) }}
run: |
commits_json=$(echo '${{ toJSON(github.event.commits) }}' | jq -c '[.[].id]')
commits_json=$(echo "$COMMITS" | jq -c '[.[].id]')
echo "commits=${commits_json}" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -72,7 +74,7 @@ jobs:
target_milestone=$(gh pr view ${{ steps.commit.outputs.pr_number }} --json milestone --jq .milestone.title)
milestones=$(gh api /repos/:owner/:repo/milestones --jq '.[].title')
echo $milestones
echo "Milestones configured in the repo: $milestones"
# Remove Backlog from the backport target branch
milestones=($milestones)
Expand All @@ -81,17 +83,15 @@ jobs:
unset 'milestones[$i]'
fi
done
echo "${milestones[@]}"
for i in "${!milestones[@]}"; do
if ! git ls-remote --heads | grep -q "refs/heads/${milestones[$i]}\$"; then
unset 'milestones[$i]'
fi
done
echo "${milestones[@]}"
echo "Milestones with the corresponding release branch: ${milestones[@]}"
sort_milestones=($(printf "%s\n" "${milestones[@]}" | sort -r))
echo "${sort_milestones[@]}"
for i in "${!sort_milestones[@]}"; do
if [[ "${sort_milestones[$i]}" == "$target_milestone" ]]; then
target_milestones=("${sort_milestones[@]:0:$((i+1))}")
Expand All @@ -118,7 +118,7 @@ jobs:
curl -X DELETE "${{ secrets.KVSTORE_URL }}/?key=base_$pr_base" \
-H "Authorization: Bearer ${{ secrets.KVSTORE_TOKEN }}"
matrix=$(printf '%s\n' "${target_milestones[@]}" | grep -v '^$' | jq -R . | jq -sc .)
matrix=$(printf '%s\n' "${target_branches[@]}" | grep -v '^$' | jq -R . | jq -sc .)
echo "matrix=$matrix" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ github.token }}
Expand Down

0 comments on commit f917ded

Please sign in to comment.