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 <satadru@gmail.com>

* Use curl for connecting to github API to add reviewer team to automated PRs.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Move adding reviewers to a separate step.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

---------

Signed-off-by: Satadru Pramanik <satadru@gmail.com>
This commit is contained in:
Satadru Pramanik, DO, MPH, MEng
2024-11-27 23:22:21 -05:00
committed by GitHub
parent 890b9eea93
commit d63f2ec945

View File

@@ -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"]}'