Skip to content

Instantly share code, notes, and snippets.

@robinmitra
Last active May 9, 2019 16:22
Show Gist options
  • Save robinmitra/e0b2f8f188ca8432dc7381e6ea5770ab to your computer and use it in GitHub Desktop.
Save robinmitra/e0b2f8f188ca8432dc7381e6ea5770ab to your computer and use it in GitHub Desktop.
Post comment on multiple Pull Requests
#!/usr/bin/env bash
GITHUB_USERNAME=<username>
GITHUB_ACCESS_TOKEN=<access-token>
REPO_URL=https://api.github.com/repos/<repo-owner>/<repo>
PR_BASE_URL=${REPO_URL}/pulls
COMMENT_BASE_URL=${REPO_URL}/issues
open_pr_ids=$(curl -u ${GITHUB_USERNAME}:${GITHUB_ACCESS_TOKEN} \ ${PR_BASE_URL}?state=open \
| jq -r '[.[] | .number] | join(" ")')
for id in ${open_pr_ids}; do
curl \
-u ${GITHUB_USERNAME}:${GITHUB_ACCESS_TOKEN} ${COMMENT_BASE_URL}/${id}/comments \
-d '{"body": "PR updated"}'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment