Skip to content

Instantly share code, notes, and snippets.

@tmclnk
Created April 18, 2022 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmclnk/8fb4b239a2fbe72c8760a02e0cde3a64 to your computer and use it in GitHub Desktop.
Save tmclnk/8fb4b239a2fbe72c8760a02e0cde3a64 to your computer and use it in GitHub Desktop.
dump latest hash
#!/usr/bin/env bash
github_pat=$(bw get password "github pat")
owner=dmsi-io
branch=develop
declare -A repos
repos[accounts-receivable-api]=develop
repos[users-api]=develop
repos[session-api]=develop
repos[houston-api-docs]=main
for entry in ${!repos[@]}; do
repo=$entry
branch="${repos[$entry]}"
hash=$(curl -s -H "Authorization: token $github_pat" \
-H "Accept: application/vnd.github.v3.sha" \
"https://api.github.com/repos/$owner/$repo/commits/$branch")
jq -n --arg repo "$repo" --arg hash "$hash" --arg short "${hash:0:7}" \
'{ "repo":$repo, "hash":$hash, short:$short }'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment