Skip to content

Instantly share code, notes, and snippets.

@lukehinds
Created June 17, 2024 08:44
Show Gist options
  • Save lukehinds/32430c37dadad316832e054240a07042 to your computer and use it in GitHub Desktop.
Save lukehinds/32430c37dadad316832e054240a07042 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Function to get the SHA for a specific tag
get_sha_for_tag() {
local owner_repo=$1
local tag=$2
curl -s "https://api.github.com/repos/$owner_repo/git/ref/tags/$tag" | jq -r '.object.sha'
}
# Example usage
# Set the owner/repo and tag you are interested in
OWNER_REPO="actions/checkout"
TAG="v2"
# Get the SHA for the specified tag
SHA=$(get_sha_for_tag $OWNER_REPO $TAG)
# Print the uses line for the workflow
echo "- uses: $OWNER_REPO@$SHA"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment