Has anyone worked on getting the current git tag/c...
# seed
o
Has anyone worked on getting the current git tag/commit hash into their logs? I do this on the front end using
git-revision-webpack-plugin
but using
serverless-bundle
with esbuild for the backend. Easiest - although janky - way forward would to somehow add the current commit/tag as a env variable for the lambda, which it can then read for logs?
f
That sounds like a reasonable solution.
SEED_BUILD_SERVICE_SHA
is available in the build environment and has the commit hash.
o
Hmm, so I’d need to write a script to take that, find out what lambdas are in the service and update the env vars via an AWS API
Might be easier to run it pre-build and write it to a file. I think that file would need to be imported instead of loaded via
readFileSync
so that esbuild picks it up
f
I was thinking setting it in SST:
Copy code
app.setDefaultFunctionProps({
  environment: {
    GIT_COMMIT: process.env.SEED_BUILD_SERVICE_SHA,
  }
});
o
ahh ok yeah that’s much cleaner and on the SLS side it’d be:
Copy code
environment:
  GIT_COMMIT: ${env:SEED_BUILD_SERVICE_SHA}
f
yes sir!
o
Praise the Frank! 🤚