Skip to content

Commit

Permalink
add commit hash to metadata (#589)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-babylonlabs authored Jan 8, 2025
1 parent 6adee0f commit 8200f7c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
NEXT_PUBLIC_NETWORK=${{ vars.NEXT_PUBLIC_NETWORK }}
NEXT_PUBLIC_DISPLAY_TESTING_MESSAGES=${{ vars.NEXT_PUBLIC_DISPLAY_TESTING_MESSAGES }}
NEXT_PUBLIC_SENTRY_DSN=${{ vars.NEXT_PUBLIC_SENTRY_DSN }}
NEXT_PUBLIC_COMMIT_HASH=${{ github.sha }}
- name: Upload Docker image to workspace
uses: actions/upload-artifact@v4
with:
Expand Down
3 changes: 3 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ ENV NEXT_PUBLIC_DISPLAY_TESTING_MESSAGES=${NEXT_PUBLIC_DISPLAY_TESTING_MESSAGES}
ARG NEXT_PUBLIC_SENTRY_DSN
ENV NEXT_PUBLIC_SENTRY_DSN=${NEXT_PUBLIC_SENTRY_DSN}

ARG NEXT_PUBLIC_COMMIT_HASH
ENV NEXT_PUBLIC_COMMIT_HASH=$NEXT_PUBLIC_COMMIT_HASH

RUN npm run build

# Step 2. Production image, copy all the files and run next
Expand Down
4 changes: 4 additions & 0 deletions src/app/components/Meta/MetaTags.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { getNetworkAppUrl } from "@/config";
import { getCommitHash } from "@/utils/version";

export default function MetaTags() {
const commitHash = getCommitHash();

return (
<>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
Expand All @@ -18,6 +21,7 @@ export default function MetaTags() {
<meta name="twitter:image:type" content="image/png" />
<meta name="twitter:image:width" content="2048" />
<meta name="twitter:image:height" content="1170" />
<meta name="version" content={commitHash} />
</>
);
}
7 changes: 7 additions & 0 deletions src/utils/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const getCommitHash = () => {
try {
return process.env.NEXT_PUBLIC_COMMIT_HASH || "development";
} catch {
return "development";
}
};

0 comments on commit 8200f7c

Please sign in to comment.