-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathschema-change-check.wac.ts
77 lines (67 loc) · 1.6 KB
/
schema-change-check.wac.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { Workflow, NormalJob, Step, multilineString } from '../src'
const checkout = new Step({
name: 'Checkout',
uses: 'actions/checkout@v4',
})
const installNode = new Step({
name: 'Install Node',
uses: 'actions/setup-node@v4',
with: { 'node-version': 20 },
})
const installGlobalTsx = new Step({
name: 'Install tsx',
run: 'npm install -g tsx',
})
const installPnpm = new Step({
name: 'Install pnpm',
uses: 'pnpm/action-setup@v4',
with: { version: 8 },
})
const installDependencies = new Step({
name: 'Install Dependencies',
run: 'pnpm install --no-frozen-lockfile',
})
const generateWorkflowTypes = new Step({
name: 'Generate Workflow Types',
run: 'pnpm generate-workflow-types',
})
const gitDiff = new Step({
name: 'Get git diff',
run: `git diff -- ':!pnpm-lock.yaml'`,
})
const isGitDiffEmpty = new Step({
name: 'Fail if git diff is not empty',
run: multilineString(
`if test -z "$(git diff --name-only -- ':!pnpm-lock.yaml')"; then`,
` echo "No file changes detected."`,
` exit 0`,
`else`,
` echo "File changes detected."`,
` exit 1`,
`fi`,
),
})
const schemaChangeCheck = new NormalJob('SchemaChangeCheck', {
'runs-on': 'ubuntu-latest',
permissions: {
contents: 'write',
},
}).addSteps([
checkout,
installNode,
installGlobalTsx,
installPnpm,
installDependencies,
generateWorkflowTypes,
gitDiff,
isGitDiffEmpty,
])
export const schemaChangeCheckWorkflow = new Workflow('schema-change-check', {
name: 'Schema Change Check',
on: {
pull_request: {
types: ['opened', 'reopened', 'synchronize'],
},
schedule: [{ cron: '0 0 * * *' }],
},
}).addJob(schemaChangeCheck)