Skip to content

Commit 2967db7

Browse files
committed
Expose current commit sha
1 parent 31f7c42 commit 2967db7

File tree

5 files changed

+20
-4
lines changed

5 files changed

+20
-4
lines changed

.babelrc

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
{
2-
"presets": [
3-
"@babel/preset-env",
4-
"@babel/preset-typescript"
5-
],
2+
"presets": ["@babel/preset-env", "@babel/preset-typescript"],
63
"plugins": [
74
"babel-plugin-macros",
85
[

.github/workflows/deployment.yml

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ jobs:
1111
steps:
1212
- name: Checkout
1313
uses: actions/checkout@v3
14+
- name: Prep the environment
15+
run: echo "VITE_COMMIT_ID=${GITHUB_SHA}" >> $GITHUB_ENV
1416
- name: Deps
1517
run: npm ci
1618
- name: Tests

src/App.test.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ jest.mock('streamr-client', () => ({
99
},
1010
}))
1111

12+
jest.mock('$/utils/getCommitId', () => ({
13+
__esModule: true,
14+
default: () => 'COMMIT_ID',
15+
}))
16+
1217
describe('Getting into the app', () => {
1318
it('displays different wallet options in the wallet modal', async () => {
1419
render(<App />)

src/App.tsx

+9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { Provider } from 'react-redux'
55
import store from '$/store'
66
import IndexPage from '$/components/IndexPage'
77
import Toaster from '$/components/Toaster'
8+
import { Helmet } from 'react-helmet'
9+
import getCommitId from '$/utils/getCommitId'
810

911
const customGlobalStyles = css`
1012
body {
@@ -81,8 +83,15 @@ const customGlobalStyles = css`
8183
`
8284

8385
export default function App() {
86+
const commitId = getCommitId()
87+
8488
return (
8589
<Provider store={store}>
90+
{commitId && (
91+
<Helmet>
92+
<meta name="commit" content={commitId} />
93+
</Helmet>
94+
)}
8695
<GlobalStyles />
8796
<Global styles={customGlobalStyles} />
8897
<div>

src/utils/getCommitId.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function getCommitId(): string | undefined {
2+
return import.meta.env.VITE_COMMIT_ID || undefined
3+
}

0 commit comments

Comments
 (0)