From d63f2ec945b33ebca86fc045d947dff4b479031a Mon Sep 17 00:00:00 2001 From: "Satadru Pramanik, DO, MPH, MEng" Date: Wed, 27 Nov 2024 23:22:21 -0500 Subject: [PATCH] Use curl for connecting to github API to add reviewer team to automated PRs (#10813) * Add workaround for gh cli not being able to add reviewer teams to PRs. Signed-off-by: Satadru Pramanik * Use curl for connecting to github API to add reviewer team to automated PRs. Signed-off-by: Satadru Pramanik * Move adding reviewers to a separate step. Signed-off-by: Satadru Pramanik --------- Signed-off-by: Satadru Pramanik --- .github/workflows/Updater.yml | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/Updater.yml b/.github/workflows/Updater.yml index 26c2839c4..4226bb954 100644 --- a/.github/workflows/Updater.yml +++ b/.github/workflows/Updater.yml @@ -178,7 +178,7 @@ jobs: "satmandu/crewbuild:${CONTAINER}" \ /bin/chromebrewstart /output/tools/github_actions_update_builder.sh > >(tee -a /tmp/build.log) 2> >(tee -a /tmp/build.log >&2) grep "Built and Uploaded:" /tmp/build.log - sudo rm -rf release manifest + sudo rm -rf release - name: Add updated packages to PR. id: push-check env: @@ -218,12 +218,18 @@ jobs: git config --global user.name 'github-actions[bot]' git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com' git fetch --depth=5 - mapfile -t updated_packages < <( git diff-tree --no-commit-id --name-only -r $(git log --oneline | grep $CREW_BRANCH | tail -n 1 | awk '{print $1}')..$(git rev-parse --verify HEAD) | grep -v manifest) - export UPDATED_FILES="Updated packages:$(echo '';for file in "${updated_packages[@]}" ; do echo "- ${file}" ; done)" - gh pr create --title "Automatic PR to update packages for ${{ needs.update-check.outputs.output1 }}" --body "${UPDATED_FILES}" - gh api \ - --method POST \ + mapfile -t updated_package_array < <( git diff-tree --no-commit-id --name-only -r $(git log --oneline | grep $CREW_BRANCH | tail -n 1 | awk '{print $1}')..$(git rev-parse --verify HEAD) | grep -v manifest | grep "^packages" | sed -e 's,packages/,,' -e 's,.rb,,') + UPDATED_PACKAGES="Updated packages: + $(for file in "${updated_package_array[@]}" ; do echo "- ${file}" ; done)" + echo "${UPDATED_PACKAGES}" + gh pr create --title "Automatic PR to update packages for ${{ needs.update-check.outputs.output1 }}" --body "${UPDATED_PACKAGES}" + - name: Add active team reviewers to PR + run: | + export PR_NUMBER="$(gh pr list --search ${{ needs.update-check.outputs.output1 }} --json number | jq -r '.[].number')" + echo "PR is #${PR_NUMBER}" + curl -X POST \ -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"\ -H "X-GitHub-Api-Version: 2022-11-28" \ - /repos/${{ github.repository }}/pulls/$(gh pr list --search ${{ needs.update-check.outputs.output1 }} --json number | jq -r '.[].number')/requested_reviewers \ - -f "team_reviewers[]=active" + https://api.github.com/repos${{ github.owner }}/${{ github.repository }}/pulls/${PR_NUMBER}/requested_reviewers \ + -d '{"team_reviewers":["active"]}'