Last active
March 19, 2019 10:04
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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