From f917dede90a6dc3d491b0c49d8c9b6aa3e5e7a27 Mon Sep 17 00:00:00 2001 From: Sion Kang Date: Thu, 19 Dec 2024 15:07:40 +0900 Subject: [PATCH] ci: Fix matrix variable to use target_branches (#3274) Co-authored-by: Joongi Kim --- .github/workflows/backport.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index d48714eb899..0fe86ebe09a 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -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 @@ -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) @@ -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))}") @@ -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 }}