SHA of currently deployed release

I would like to access the Git SHA of the currently deployed release when my app is started.
I expected a env var that contains it but couldn’t find one…
Can I set it myself in my app’s Dockerfile or fly.toml?
Any ideas are appreciated! :smile:

We tag our images with the commit-sha instead of burning it in an env (which is mutable), which then appears in our FLY VM as FLY_IMAGE_REF=registry.fly.io/<appname>@sha256:<sha256>

FLY_TOML = "fly.toml"
# or use rolling
FLY_DEPLOY_START="immediate"
# or use {{ github.sha }}
GIT_HEAD=$(git rev-parse HEAD)

flyctl deploy
        --image-label GIT_HEAD
        --config FLY_TOML
        --strategy FLY_DEPLOY_STRAT
        --auto-confirm
        --verbose

If you use github-actions, then see: serverless-dns/fly.yml at 8a07a50e901ec16045b6de1d90036a81ebf4c872 · serverless-dns/serverless-dns · GitHub

Great, thanks! I’ll use FLY_IMAGE_REF to get the SHA.

Or could I easily set a separate env var in the Dockerfile?

In case you misunderstood it… by default, Fly doesn’t burn in the commit-sha. You’d have to explicitly pass it along with the flyctl deploy --image-label <sha> <other-args> switch (note the I shared cmd above).

Yep, that works just as nicely.

In case you misunderstood it… by default, Fly doesn’t burn in the commit-sha. You’d have to explicitly pass it along with the flyctl deploy --image-label <sha> <other-args> switch (note the I shared cmd above).

Are you sure? When I check the VMs of all the apps I have deployed on Fly, FLY_IMAGE_REF is there (and I haven’t used the --image-label ever).