From 5912390c428a13b31a4cda5d3e665f05e52a1e97 Mon Sep 17 00:00:00 2001 From: Sion Kang Date: Thu, 19 Dec 2024 14:40:31 +0900 Subject: [PATCH 1/5] ci: backport to handle commit messages safely --- .github/workflows/backport.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index d48714eb89..49c61fc781 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 From 59a9a13b5e09327b44e0d0234665b024a21d0d2a Mon Sep 17 00:00:00 2001 From: Sion Kang Date: Thu, 19 Dec 2024 14:46:47 +0900 Subject: [PATCH 2/5] Fix matrix variable to use target_branches --- .github/workflows/backport.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index 49c61fc781..8eea483502 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -120,7 +120,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 }} From a34c12538b8b5ff7dfa5b4620bb60b07acecfce5 Mon Sep 17 00:00:00 2001 From: Sion Kang Date: Thu, 19 Dec 2024 14:54:08 +0900 Subject: [PATCH 3/5] Update backport.yml --- .github/workflows/backport.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index 8eea483502..42fc24334e 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -74,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: $milestones" # Remove Backlog from the backport target branch milestones=($milestones) @@ -83,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 "Released milestones: ${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))}") From d5e58efe4b2c6a3e5beca95e912d8ff559e6350f Mon Sep 17 00:00:00 2001 From: Sion Kang Date: Thu, 19 Dec 2024 15:06:01 +0900 Subject: [PATCH 4/5] Update .github/workflows/backport.yml Co-authored-by: Joongi Kim --- .github/workflows/backport.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index 42fc24334e..16378eba11 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -74,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: $milestones" + echo "Milestones configured in the repo: $milestones" # Remove Backlog from the backport target branch milestones=($milestones) From 10f97f7641f6fffbefb09aa3f2507cd24a1e87b1 Mon Sep 17 00:00:00 2001 From: Sion Kang Date: Thu, 19 Dec 2024 15:06:09 +0900 Subject: [PATCH 5/5] Update .github/workflows/backport.yml Co-authored-by: Joongi Kim --- .github/workflows/backport.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index 16378eba11..0fe86ebe09 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -89,7 +89,7 @@ jobs: unset 'milestones[$i]' fi done - echo "Released milestones: ${milestones[@]}" + echo "Milestones with the corresponding release branch: ${milestones[@]}" sort_milestones=($(printf "%s\n" "${milestones[@]}" | sort -r)) for i in "${!sort_milestones[@]}"; do