Skip to content

Instantly share code, notes, and snippets.

@koenrh
Last active March 19, 2019 10:04
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koenrh/66f3d6833f8096282538 to your computer and use it in GitHub Desktop.
Save koenrh/66f3d6833f8096282538 to your computer and use it in GitHub Desktop.
Run bundle-audit on all repositories in your GitHub organisations. Requires jsawk and bundler-audit.
#!/bin/bash
org=blendle
token=$GITHUB_BUNDLE_AUDIT_API_TOKEN
gh_api_host=api.github.com
gh_raw_host=raw.githubusercontent.com
gh_repos_url="https://$gh_api_host/orgs/$org/repos?type=sources&per_page=1000"
bundle-audit update
for repo in $(curl -s -H "Authorization: token $token" "$gh_repos_url" | jsawk -n 'out(this.name)'); do
printf "%sAuditing%s: %s\n" "$(tput setaf 6)" "$(tput sgr 0)" "$repo"
status=$(curl -s -H "Authorization: token $token" --write-out "%{http_code}" -O "https://$gh_raw_host/$org/$repo/master/{Gemfile,Gemfile.lock}")
if [ "$status" = 200200 ]; then
bundle-audit check
rm Gemfile Gemfile.lock
else
printf "%sNo Gemfile and/or Gemfile.lock%s" "$(tput setaf 3)" "$(tput sgr 0)"
fi
printf "\n\n"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment