Know commit hash of running worker

When the worker is deployed I would like to have a way for the worker to know what is the commit version that was used to build/ship it. Kind of like having an env var that stores the output of git rev-parse HEAD that i can just reference in the worker's code itself.
1 Reply
veeque
veequeOP6d ago
i can add --var GIT_HASH:$(git rev-parse HEAD) to the dev and deploy commands. the issue is now typescript has no idea this var exists i could define it in vars in the config with the --strict-vars false flag but idk, seem not ideal ended up just making my own d.ts file
declare namespace Cloudflare {
interface Env {
GIT_HASH: string;
}
}
declare namespace Cloudflare {
interface Env {
GIT_HASH: string;
}
}

Did you find this page helpful?