Skip to content

Instantly share code, notes, and snippets.

@farhad-taran
Created February 12, 2025 16:40
Show Gist options
  • Save farhad-taran/052b076d56424958c0b587b24eceab23 to your computer and use it in GitHub Desktop.
Save farhad-taran/052b076d56424958c0b587b24eceab23 to your computer and use it in GitHub Desktop.
How to tag commits based on the type of files changed

In some instances we need to tag commits for deployments, however the deployment might be unnecessary if the only file that has been changed in the commit is not app related, so you will be redeploying a no change package.

we can get the latest commit that has changed a specific file type using the following command:

GLOB_PATTERN="-- \apps/*  -- \libs/*  -- \*.tsx -- \*.ts -- \*.js -- \*.tf -- \*.json -- \*.yml -- \*.yaml"
GLOB_COMMIT=$(git log -n 1 --pretty=format:%H $GLOB_PATTERN)

the above command essentially gets the last commit hash where a file has been changed in the apps or libs folder, or if the commit has had a change to file with certain extensions.

we can also use the following command to delete any test tags that we have created:

git push -d origin $(git tag -l "test*")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment