Skip to content

Commit 1e4d0b2

Browse files
vsilentCopilot
andcommitted
ci: push image to vsilent/stackdog:latest with git hash baked in
- docker.yml now pushes to vsilent/stackdog:latest (and :<sha> tag) - STACKDOG_GIT_HASH injected via env during cross build so the hash survives inside the cross Docker container - build.rs reads STACKDOG_GIT_HASH env var first, falls back to running git locally Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 93b9284 commit 1e4d0b2

2 files changed

Lines changed: 16 additions & 9 deletions

File tree

.github/workflows/docker.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343
- name: Build static release
4444
env:
4545
CARGO_TARGET_DIR: target-cross
46+
STACKDOG_GIT_HASH: ${{ github.sha }}
4647
run: cross build --release --target x86_64-unknown-linux-musl
4748

4849
- name: Build frontend
@@ -98,4 +99,6 @@ jobs:
9899
with:
99100
context: .
100101
push: true
101-
tags: trydirect/stackdog:latest
102+
tags: |
103+
vsilent/stackdog:latest
104+
vsilent/stackdog:${{ github.sha }}

build.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
use std::process::Command;
22

33
fn main() {
4-
let hash = Command::new("git")
5-
.args(["rev-parse", "--short", "HEAD"])
6-
.output()
7-
.ok()
8-
.filter(|o| o.status.success())
9-
.and_then(|o| String::from_utf8(o.stdout).ok())
10-
.map(|s| s.trim().to_string())
11-
.unwrap_or_else(|| "unknown".to_string());
4+
// Allow CI (or any build environment) to inject the hash directly.
5+
// Falls back to running `git rev-parse --short HEAD` locally.
6+
let hash = std::env::var("STACKDOG_GIT_HASH").unwrap_or_else(|_| {
7+
Command::new("git")
8+
.args(["rev-parse", "--short", "HEAD"])
9+
.output()
10+
.ok()
11+
.filter(|o| o.status.success())
12+
.and_then(|o| String::from_utf8(o.stdout).ok())
13+
.map(|s| s.trim().to_string())
14+
.unwrap_or_else(|| "unknown".to_string())
15+
});
1216

1317
println!("cargo:rustc-env=STACKDOG_GIT_HASH={hash}");
1418
println!("cargo:rerun-if-changed=.git/HEAD");

0 commit comments

Comments
 (0)