Skip to content

Commit 7edf99f

Browse files
authored
add pr job (#34)
1 parent 92ed315 commit 7edf99f

10 files changed

Lines changed: 66 additions & 19 deletions

File tree

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
name: Deploy Dev
1+
name: Release Dev
22

33
on:
44
push:
5-
branches: ["main"]
5+
branches:
6+
- main
67

78
jobs:
8-
deploy-dev:
9-
name: Deploy Dev
9+
call-function:
10+
name: Call function
1011
runs-on: ubuntu-latest
1112
steps:
1213
- uses: actions/checkout@v4
@@ -23,8 +24,8 @@ jobs:
2324
run: yarn install
2425

2526
- name: Call script
26-
working-directory: ./scripts/ci
27-
run: ./release-dev.ts
27+
working-directory: ./scripts/pipelines
28+
run: ./release.ts
2829
env:
2930
MODE: "dev"
3031
GH_TOKEN: ${{ secrets.GH_TOKEN_DEV }}

.github/workflows/validate-pr.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Validate PR
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
call-function:
10+
name: Call function
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Setup Dagger
16+
uses: dagger/dagger-for-github@v5
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: 20
22+
23+
- name: Install dependencies
24+
run: yarn install
25+
26+
- name: Call script
27+
working-directory: ./scripts/pipelines
28+
run: ./validate-pr.ts
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import { css } from "@emotion/react";
22

3-
import { AppTheme } from "@/theme";
4-
53
export const styles = {
6-
main: (theme: AppTheme) =>
7-
css({
8-
minHeight: "95vh",
9-
marginInline: theme.spacing(2),
10-
}),
4+
main: css({
5+
minHeight: "95vh",
6+
}),
117
};

dagger/main.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,23 @@ func (m *NdthanhdevGithubIo) Init(ctx context.Context, dir *Directory) *Containe
4040
WithExec([]string{"yarn", "install", "--immutable"})
4141
}
4242

43+
func (m *NdthanhdevGithubIo) Lint(ctx context.Context, dir *Directory) (string, error) {
44+
return m.Init(ctx, dir).
45+
WithWorkdir("/mnt/scripts/actions").
46+
WithExec([]string{"./lint.ts"}).
47+
Stdout(ctx)
48+
}
49+
50+
func (m *NdthanhdevGithubIo) Test(ctx context.Context, dir *Directory) (string, error) {
51+
return m.Init(ctx, dir).
52+
WithWorkdir("/mnt/scripts/actions").
53+
WithExec([]string{"./test.ts"}).
54+
Stdout(ctx)
55+
}
56+
4357
func (m *NdthanhdevGithubIo) Build(ctx context.Context, dir *Directory) *Directory {
4458
return m.Init(ctx, dir).
45-
WithWorkdir("/mnt/scripts").
59+
WithWorkdir("/mnt/scripts/actions").
4660
WithExec([]string{"./build.ts"}).
4761
Directory("/mnt/app/public")
4862
}
@@ -54,7 +68,7 @@ func (m *NdthanhdevGithubIo) Publish(ctx context.Context, dir *Directory, mode s
5468
return m.Init(ctx, dir).
5569
WithEnvVariable("GH_TOKEN", tokenString).
5670
WithEnvVariable("MODE", mode).
57-
WithWorkdir("/mnt/scripts").
71+
WithWorkdir("/mnt/scripts/actions").
5872
WithExec([]string{"./publish.ts"}).
5973
Stdout(ctx)
6074
}
File renamed without changes.

scripts/actions/test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env -S yarn dlx tsx
2+
import "zx/globals";
3+
4+
import { pipeOutput } from "~/utils/pipe-output";
5+
import { workDirs } from "~/utils/work-dir";
6+
7+
cd(workDirs.app.path);
8+
9+
await pipeOutput($`yarn typecheck`);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ cd(workDirs.path);
1010

1111
await $`dagger call build --dir . export --path ${workDirs.app.public.path}`;
1212

13-
await $`dagger call publish --dir . --token env:GH_TOKEN --mode dev`;
13+
await $`dagger call publish --dir . --token env:GH_TOKEN --mode ${$.env.MODE ?? "dev"}`;
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ await cleanBuild();
88

99
cd(workDirs.path);
1010

11-
await $`dagger call build --dir . export --path ${workDirs.app.public.path}`;
12-
13-
await $`dagger call publish --dir . --token env:GH_TOKEN --mode prod`;
11+
await $`dagger call lint --dir .`;
12+
await $`dagger call test --dir .`;

0 commit comments

Comments
 (0)