Skip to content

Commit 6041048

Browse files
authored
add mode (#44)
1 parent 818dce5 commit 6041048

7 files changed

Lines changed: 23 additions & 8 deletions

File tree

app/src/components/organisms/app-footer/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,19 @@ export type AppFooterProps = React.PropsWithChildren<{
99
year: string;
1010
buildNumber: string;
1111
rev: string;
12+
mode: string;
1213
}>;
1314

14-
export const AppFooter = ({ year, buildNumber, rev }: AppFooterProps) => (
15+
export const AppFooter = ({ year, buildNumber, rev, mode }: AppFooterProps) => (
1516
<Box css={styles.root}>
1617
<Divider />
1718
<Box css={styles.contentContainer}>
1819
<Box css={styles.topWrapper}>
1920
<Box css={styles.leftWrapper}>
2021
<Typography variant="caption">{`Copyright © ${year}`}</Typography>
21-
<Typography variant="caption">{`Build: ${buildNumber}`}</Typography>
2222
<Typography variant="caption">{`Rev: ${rev}`}</Typography>
23+
<Typography variant="caption">{`Build: ${buildNumber}`}</Typography>
24+
<Typography variant="caption">{`Mode: ${mode}`}</Typography>
2325
</Box>
2426
<Box css={styles.rightWrapper}>
2527
<Link

app/src/hooks/use-main-template-props.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export const useMainTemplateProps = (): MainTemplateProps => {
2929
year,
3030
buildNumber: envs.buildNumber,
3131
rev: envs.rev,
32+
mode: envs.mode,
3233
},
3334
};
3435
};

app/src/utils/envs.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
const buildNumber = process.env.GATSBY_BUILD_NUMBER || "local",
2-
rev = process.env.GATSBY_REV || "local";
1+
const buildNumber = process.env.GATSBY_BUILD_NUMBER || "local";
2+
const rev = process.env.GATSBY_REV || "local";
3+
const mode = process.env.GATSBY_LOCAL || "local";
34

4-
export const envs = { buildNumber, rev };
5+
export const envs = { buildNumber, rev, mode };

dagger/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ func (m *NdthanhdevGithubIo) Test(ctx context.Context, dir *Directory) (string,
5454
Stdout(ctx)
5555
}
5656

57-
func (m *NdthanhdevGithubIo) Build(ctx context.Context, dir *Directory) *Directory {
57+
func (m *NdthanhdevGithubIo) Build(ctx context.Context, dir *Directory, mode string) *Directory {
5858
return m.Init(ctx, dir).
5959
WithWorkdir("/mnt/scripts/actions").
60+
WithEnvVariable("MODE", mode).
6061
WithExec([]string{"./build.ts"}).
6162
Directory("/mnt/app/public")
6263
}

scripts/actions/build.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ cd(workDirs.app.path);
1212

1313
$.env.GATSBY_BUILD_NUMBER = getBuildNumber();
1414
$.env.GATSBY_REV = await getRev();
15+
$.env.GATSBY_MODE = $.env.MODE;
1516

1617
await $`yarn build`;

scripts/pipelines/release.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ await cleanBuild();
88

99
cd(workDirs.path);
1010

11-
await $`dagger call build --dir . export --path ${workDirs.app.public.path}`;
11+
await $`dagger call build \
12+
--dir . \
13+
--mode ${$.env.MODE ?? "dev"} \
14+
export --path ${workDirs.app.public.path} \
15+
`;
1216

13-
await $`dagger call publish --dir . --token env:GH_TOKEN --mode ${$.env.MODE ?? "dev"}`;
17+
await $`dagger call publish \
18+
--dir . \
19+
--token env:GH_TOKEN \
20+
--mode ${$.env.MODE ?? "dev"} \
21+
`;

scripts/utils/node.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ declare module "process" {
66
GH_TOKEN?: string;
77
GATSBY_BUILD_NUMBER?: string;
88
GATSBY_REV?: string;
9+
GATSBY_MODE?: "dev" | "stg" | "prod";
910
}
1011
}
1112
}

0 commit comments

Comments
 (0)