Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
Merge pull request #46 from himmelblau-idm/dmulder/dependabot_automerge
Browse files Browse the repository at this point in the history
Include the automerge script for dependabot
  • Loading branch information
dmulder authored Mar 26, 2024
2 parents a92c4e3 + f5ecd9b commit fdca9a0
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions scripts/dependabot_automerge_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

if [ -z "$1" ]; then
echo "Specify the PR URL"
exit 1
fi

PR_URL="$1"

# sets the upstream metadata for `gh pr status`
gh pr checkout "$PR_URL"


# are we good?
echo "Checking Conclusions"
CONCLUSIONS="$(gh pr status --json statusCheckRollup | jq '.currentBranch | .[] | .[] | select(.conclusion != "SUCCESS") | select(.conclusion != "NEUTRAL")| {status: .status, workfFlowName: .workFlowName, conclusion: .conclusion}')"



if [ "$(echo "${CONCLUSIONS}" | wc -l)" -eq 0 ]; then
gh pr review --approve "$PR_URL"
else
echo "Already running or failed: ${CONCLUSIONS}";
fi

if [ "${APPROVED}" != "APPROVED" ]; then
echo "PR isn't approved!"
exit 0
fi

# check approval
echo "Checking if already approved...."
APPROVED="$(gh pr status --json reviewDecision -q .currentBranch.reviewDecision)"

0 comments on commit fdca9a0

Please sign in to comment.