Browse Source

Display GitHub commit hash in interface

Eric Zhang 4 years ago
parent
commit
1a626bb228
3 changed files with 8 additions and 1 deletions
  1. 1 0
      .github/workflows/ci.yml
  2. 2 0
      Dockerfile
  3. 5 1
      src/App.tsx

+ 1 - 0
.github/workflows/ci.yml

@@ -27,6 +27,7 @@ jobs:
         uses: docker/build-push-action@v2
         with:
           push: true
+          build-args: GITHUB_SHA
           tags: ekzhang/rustpad:latest
 
       - name: Image digest

+ 2 - 0
Dockerfile

@@ -17,6 +17,8 @@ COPY package.json package-lock.json ./
 COPY --from=wasm /home/rust/src/rustpad-wasm/pkg rustpad-wasm/pkg
 RUN npm ci
 COPY . .
+ARG GITHUB_SHA
+ENV REACT_APP_SHA=${GITHUB_SHA}
 RUN npm run build
 
 FROM scratch

+ 5 - 1
src/App.tsx

@@ -25,6 +25,10 @@ import languages from "./languages.json";
 
 set_panic_hook();
 
+const version = process.env.REACT_APP_SHA
+  ? process.env.REACT_APP_SHA.slice(0, 7)
+  : "development";
+
 const id = window.location.hash.slice(1);
 const wsUri =
   (window.location.origin.startsWith("https") ? "wss://" : "ws://") +
@@ -201,7 +205,7 @@ function App() {
           align="center"
         >
           <Icon as={VscRemote} mb={-0.5} mr={1} />
-          <Text fontSize="xs">Rustpad v0.1.0</Text>
+          <Text fontSize="xs">Rustpad ({version})</Text>
         </Flex>
       </Flex>
     </Flex>