Skip to content

Commit

Permalink
amend and simplify auto-dependabot job
Browse files Browse the repository at this point in the history
  • Loading branch information
xavpaice committed Feb 21, 2024
1 parent 533b6f1 commit 5a279a9
Showing 1 changed file with 13 additions and 23 deletions.
36 changes: 13 additions & 23 deletions .github/workflows/automated-prs-manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,13 @@ jobs:
# list prs that are less than 24h old and exclude prs from forks
dependabot_prs=$(
prs=$(
gh pr list \
--author 'dependabot[bot]' \
--json url,createdAt,headRefName,headRepository,headRepositoryOwner \
-q '.[] | select((.createdAt | fromdateiso8601 > now - 24*60*60) and .headRepositoryOwner.login == "replicatedhq" and .headRepository.name == "troubleshoot")'
)
replicated_ci_troubleshoot_prs=$(
gh pr list \
--author 'replicated-ci-troubleshoot' \
--json url,createdAt,headRefName,headRepository,headRepositoryOwner \
-q '.[] | select((.createdAt | fromdateiso8601 > now - 24*60*60) and .headRepositoryOwner.login == "replicatedhq" and .headRepository.name == "troubleshoot")'
)
prs=$(echo "$dependabot_prs" "$replicated_ci_troubleshoot_prs" | jq -sc '. | unique')
echo "prs=$prs" >> "$GITHUB_OUTPUT"
process-prs:
Expand Down Expand Up @@ -75,20 +67,18 @@ jobs:
exit 0
fi
# If all tests and required checks passed, approve and merge.
if gh run view "$run_id" --json jobs -q '.jobs[] | select(.name == "validate-success") | .conclusion' | grep -q "success"; then
if gh pr checks "${{ matrix.pr.url }}" --required; then
echo "All tests and required checks passed. Approving and merging."
echo -e "LGTM :thumbsup: \n\nThis PR was automatically approved and merged by the [automated-prs-manager](https://github.com/replicatedhq/troubleshoot/blob/main/.github/workflows/automated-prs-manager.yaml) GitHub action" > body.txt
gh pr review --approve "${{ matrix.pr.url }}" --body-file body.txt
gh pr merge --auto --squash "${{ matrix.pr.url }}"
sleep 10
exit 0
else
echo "All tests passed, but some required PR checks have not. Skipping."
exit 0
fi
# If all checks passed, approve and merge.
if gh pr checks "${{ matrix.pr.url }}" ; then
echo "All tests passed. Approving and merging."
echo -e "LGTM :thumbsup: \n\nThis PR was automatically approved and merged by the [automated-prs-manager](https://github.com/replicatedhq/troubleshoot/blob/main/.github/workflows/automated-prs-manager.yaml) GitHub action" > body.txt
gh pr review --approve "${{ matrix.pr.url }}" --body-file body.txt
gh pr merge --auto --squash "${{ matrix.pr.url }}"
sleep 10
exit 0
else
echo "Some checks did not pass. Skipping."
exit 0
fi
# If more than half of the validate-* jobs are successful, re-run the failed jobs.
Expand Down

0 comments on commit 5a279a9

Please sign in to comment.