Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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