Skip to content

Commit

Permalink
feat: コンパイル時にタグとコミットハッシュを埋め込む #10 (#195)
Browse files Browse the repository at this point in the history
* コンパイル時にリビジョンとタグ番号を埋め込むように変更

* デプロイワークフロー時にタグとリビジョンを埋め込むように変更
  • Loading branch information
jiro4989 authored Nov 26, 2020
1 parent c1cbe7d commit 491b0ca
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ jobs:
- name: Build assets
run: |
docker build --target base -t base .
docker run --rm -v $PWD/websh_front:/work -t base nimble build -Y
docker run --rm -v $PWD/websh_front:/work -t base \
nimble build -Y \
"-d:tag:${GITHUB_REF/refs?heads?}" \
"-d:revision:$GITHUB_SHA"
- name: Create artifact
run: |
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ services:
- build
- -Y
- -d:local
- -d:tag:tag
- -d:revision:rev

websh_server:
build: *app-build
Expand Down
6 changes: 6 additions & 0 deletions websh_front/src/index.nim
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ else:
const baseUrl = "https://websh.jiro4989.com"
const apiUrl = &"{baseUrl}/api/shellgei"

# コンパイル時に値を埋め込む
const tag {.strdefine.} = "v0.0.0"
const revision {.strdefine.} = "develop"

proc newMediaObj(): MediaObj = MediaObj(name: cstring"", data: cstring"")

var
Expand Down Expand Up @@ -282,6 +286,8 @@ proc createDom(): VNode =
a(href = "https://github.com/jiro4989/websh"): text "Repository"
text ", "
a(href = "https://stats.uptimerobot.com/EZnRXc325K"): text "Public Status Page"
tdiv(class = "content has-text-centered"):
text "tag: " & tag & ", revision: " & revision

when not defined modeTest:
setRenderer createDom

0 comments on commit 491b0ca

Please sign in to comment.