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

Measure quarantine from createdAt #16

Merged
merged 5 commits into from
Oct 4, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.FRECKLE_AUTOMATION_APP_ID }}
private-key: ${{ secrets.FRECKLE_AUTOMATION_APP_PRIVATE_KEY }}
private-key: ${{ secrets.FRECKLE_AUTOMATION_PRIVATE_KEY }}
repositories: megarepo

# Run once with settings that are sure to find nothing (this repository
Expand Down
16 changes: 2 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,14 @@ on:
- cron: "0 0 * * *"

pull_request:
types: [opened]
```

Mergeabot knows if it's running on a `pull_request` event in a Dependabot PR
and, if so, leaves a comment on the PR indicating, roughly, "I got this."

![Mergeabot comment on opened event](./screenshots/opened-comment.png)

When configured this way, Mergeabot will run when the PR is opened or updated,
so it can let you know that the updates have reset the clock on the quarantine:

![Mergeabot comment on synchronized event](./screenshots/synchronized-comment.png)

If you don't prefer this, just limit it to only `opened` events:

```yaml
on:
pull_request:
types: [opened]
```

## Permissions

Dependabot PRs use a token with read-only permissions by default, so you'll need
Expand All @@ -98,6 +86,7 @@ on:
- cron: "0 0 * * *"

pull_request:
types: [opened]

permissions:
contents: write
Expand Down Expand Up @@ -128,7 +117,6 @@ jobs:

- `strategy`: how to perform the [auto-]merge. Must be `merge`, `rebase`, or
`squash`. Default is `rebase`.

- `remove-reviewers`: remove any requested reviewers (if run on PRs). Default
is `true`.

Expand Down
16 changes: 4 additions & 12 deletions bin/automerge-prs
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,16 @@ if is_dependabot && ! exclude_by_title "$GH_PR_TITLE" && ! is_workflows_update "
fi
fi

cat >"$tmp/message" <<EOM
gh pr comment "$GH_PR_NUMBER" --body-file - <<EOM
:heavy_check_mark: If all status checks pass, and no other reviews are submitted, [mergeabot][] will merge this PR $when_message.

As long as that's OK, no other action is necessary.

[mergeabot]: https://github.com/freckle/mergeabot-action
EOM
;;
*)
cat >"$tmp/message" <<EOM
:clock1: PR was updated. [Mergeabot][] will now merge this PR $when_message.

[mergeabot]: https://github.com/freckle/mergeabot-action
EOM
;;
esac

gh pr comment "$GH_PR_NUMBER" --body-file "$tmp/message"
exit 0
fi

Expand All @@ -84,7 +76,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,headRefName,author,updatedAt,reviewDecision'
fields='number,title,headRefName,author,createdAt,reviewDecision'

gh_pr list --search "$search" --limit 1000 --json "$fields" --jq '.[]' |
while IFS=$'\n' read -r ln; do
Expand All @@ -98,12 +90,12 @@ 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")
createdAt=$(jq --raw-output '.createdAt' "$json")
reviewDecision=$(jq --raw-output '.reviewDecision' "$json")
found=1

printf '%s (#\e[34m%s\e[0m)\n' "$title" "$number"
printf ' Last updated: \e[35m%s\e[0m\n' "$updatedAt"
printf ' Created at: \e[35m%s\e[0m\n' "$createdAt"
printf ' Current review decision: \e[35m%s\e[0m\n' "$reviewDecision"

if exclude_by_title "$title"; then
Expand Down
Binary file removed screenshots/synchronized-comment.png
Binary file not shown.
Loading