kanidm/scripts/dependabot_automerge_check.sh
James Hodgkinson 69dfea3601
Still trying to fix the docs. (#1709)
* docs build/deploy fixes
* let us see if this makes the automerge less bad
2023-06-28 10:34:17 +10:00

27 lines
750 B
Bash
Executable file

#!/bin/bash
if [ -z "$1" ]; then
echo "Specify the PR URL"
exit 1
fi
PR_URL="$1"
# are we good?
CONCLUSIONS="$(gh pr status --json statusCheckRollup | jq '.currentBranch | .[] | .[] | select(.conclusion != "SUCCESS") | select(.conclusion != "NEUTRAL")| {status: .status, workfFlowName: .workFlowName, conclusion: .conclusion}')"
# check approval
APPROVED="$(gh pr status --json reviewDecision -q .currentBranch.reviewDecision)"
# sets the upstream metadata for `gh pr status`
gh pr checkout "$PR_URL"
if [ "${APPROVED}" != "APPROVED" ]; then
echo "PR not approved!"
exit 1
fi
if [ "$(echo "${CONCLUSIONS}" | wc -l)" -eq 0 ]; then
gh pr review --approve "$PR_URL"
else
echo "Already running or failed: ${CONCLUSIONS}";
fi