Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore PRs whose branches indicate workflows updates #11

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,4 @@ runs:
GH_PR_ACTION: ${{ github.event.action }}
GH_PR_NUMBER: ${{ github.event.number }}
GH_PR_TITLE: ${{ github.event.pull_request.title }}
GH_PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
15 changes: 13 additions & 2 deletions bin/automerge-prs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ fi
: "${GH_PR_ACTION:=""}"
: "${GH_PR_NUMBER:=""}"
: "${GH_PR_TITLE:=""}"
: "${GH_PR_HEAD_REF:=""}"

is_dependabot() {
[[ "$GH_ACTOR" == 'dependabot[bot]' ]] && [[ "$GH_EVENT" == 'pull_request' ]]
Expand All @@ -23,14 +24,18 @@ exclude_by_title() {
[[ -n "$EXCLUDE_TITLE_REGEX" ]] && [[ "$1" =~ $EXCLUDE_TITLE_REGEX ]]
}

is_workflows_update() {
[[ "$1" =~ ^dependabot/github_actions/.* ]]
}

gh_pr() {
gh pr --repo "$GH_REPO" "$@"
}

tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT

if is_dependabot && ! exclude_by_title "$GH_PR_TITLE"; then
if is_dependabot && ! exclude_by_title "$GH_PR_TITLE" && ! is_workflows_update "$GH_PR_HEAD_REF"; then
if ((QUARANTINE_DAYS <= 0)); then
when_message="the next time it runs"
else
Expand Down Expand Up @@ -79,7 +84,7 @@ since_s=$((now_s - (QUARANTINE_DAYS * 24 * 60 * 60)))
since=$(date -d "@$since_s" +"%Y-%m-%d")

search="author:app/dependabot updated:<$since"
fields='number,title,author,updatedAt,reviewDecision'
fields='number,title,headRefName,author,updatedAt,reviewDecision'

gh_pr list --search "$search" --limit 1000 --json "$fields" --jq '.[]' |
while IFS=$'\n' read -r ln; do
Expand All @@ -92,6 +97,7 @@ found=0
for json in "$tmp"/*.json; do
number=$(jq --raw-output '.number' "$json")
title=$(jq --raw-output '.title' "$json")
branch=$(jq --raw-output '.headRefName' "$json")
updatedAt=$(jq --raw-output '.updatedAt' "$json")
reviewDecision=$(jq --raw-output '.reviewDecision' "$json")
found=1
Expand All @@ -105,6 +111,11 @@ for json in "$tmp"/*.json; do
continue
fi

if is_workflows_update "$branch"; then
printf ' \e[1;37m=>\e[0m \e[33mSkip\e[0m (PR updates worflows)\n'
continue
fi

case "$reviewDecision" in
CHANGES_REQUESTED)
printf ' \e[1;37m=>\e[0m \e[33mSkip\e[0m (changes requested)\n'
Expand Down