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