Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Fix matrix variable to use target_branches #3274

Merged
merged 5 commits into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]')
Yaminyam marked this conversation as resolved.
Show resolved Hide resolved
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
Loading