Skip to content

Instantly share code, notes, and snippets.

@egregius313
Created December 31, 2022 22:54
Show Gist options
  • Save egregius313/281e269db0a8b66621a14021d7c6c1e9 to your computer and use it in GitHub Desktop.
Save egregius313/281e269db0a8b66621a14021d7c6c1e9 to your computer and use it in GitHub Desktop.
Script for pasting a list of PRs in Slack using Alfred
#!/usr/bin/env sh
# Get the GitHub username from ~/.gitconfig
USERNAME=$(git config github.user)
# Replace this with the relevant repository
REPO=github/codeql
gh pr list -A "$USERNAME" -R $REPO --json isDraft,title,labels,url \
| jq -r '
# Get the draft status of the PR and translate it to the GitHub Slack emoji
def pr_status: if .isDraft then ":pr-draft:" else ":pr-open:" end ;
# On my team, we mark whether a PR is ready for review by the documentation team with
# a label `ready-for-doc-review`. This can be changed accordingly.
def ready_for_docs_review: .labels | map(select(.name == "ready-for-doc-review")) | length > 0 ;
.[] | "- " + pr_status + (if ready_for_docs_review then " (Docs review) " else " " end) + .title + ": " + .url' \
| tac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment