Skip to content

version

gh docs version writes a small text file describing where a build came from. It is meant to be published alongside a site so a deployed version can be traced back to a commit.

Terminal window
gh docs version
gh docs version --file astro/public/version.txt

The default output is dist/version.txt. Missing parent directories are created.

Build from https://github.com/mindovermachine-dev/gh-docs
Ref: main
Commit: 0123456789abcdef0123456789abcdef01234567
FlagDefaultDescription
-c, --config.docs.ymlPath to the configuration file.
-f, --filedist/version.txtOutput path of the version file.

Each value is taken from the first source that defines it, so the command works unchanged locally and in GitHub Actions.

Value1. Explicit2. GitHub Actions3. git
RepoBUILD_REPOGITHUB_SERVER_URL + GITHUB_REPOSITORYgit remote get-url origin
RefBUILD_REFGITHUB_REF_NAMEgit branch --show-current
CommitBUILD_SHAGITHUB_SHAgit rev-parse HEAD

On a detached HEAD with no variables set, the ref is written as detached. If a value cannot be resolved from any source, for example outside a git repository, the command fails.

The version node in .docs.yml supports file. The --file flag takes precedence. See configuration.