|
1 | 1 | name: CI |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | - branches: [main, master, develop] |
6 | | - pull_request: |
7 | | - branches: [main, master, develop] |
| 4 | + push: |
| 5 | + branches: [main, master, develop] |
| 6 | + pull_request: |
| 7 | + branches: [main, master, develop] |
8 | 8 |
|
9 | 9 | jobs: |
10 | | - test: |
11 | | - name: Test and Lint |
12 | | - runs-on: ubuntu-latest |
13 | | - |
14 | | - strategy: |
15 | | - matrix: |
16 | | - node-version: [20.x] |
17 | | - |
18 | | - steps: |
19 | | - - name: Checkout code |
20 | | - uses: actions/checkout@v4 |
21 | | - |
22 | | - - name: Setup Node.js ${{ matrix.node-version }} |
23 | | - uses: actions/setup-node@v4 |
24 | | - with: |
25 | | - node-version: ${{ matrix.node-version }} |
26 | | - |
27 | | - - name: Install pnpm |
28 | | - uses: pnpm/action-setup@v4 |
29 | | - with: |
30 | | - version: 8 |
31 | | - |
32 | | - - name: Get pnpm store directory |
33 | | - shell: bash |
34 | | - run: | |
35 | | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV |
36 | | -
|
37 | | - - name: Setup pnpm cache |
38 | | - uses: actions/cache@v4 |
39 | | - with: |
40 | | - path: ${{ env.STORE_PATH }} |
41 | | - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
42 | | - restore-keys: | |
43 | | - ${{ runner.os }}-pnpm-store- |
44 | | -
|
45 | | - - name: Install dependencies |
46 | | - run: pnpm install --frozen-lockfile |
47 | | - |
48 | | - - name: Run linter |
49 | | - run: pnpm run lint |
50 | | - |
51 | | - - name: Type check |
52 | | - run: pnpm run check |
53 | | - |
54 | | - - name: Run tests |
55 | | - run: pnpm run test |
56 | | - env: |
57 | | - NODE_ENV: test |
58 | | - |
59 | | - - name: Build project |
60 | | - run: pnpm run build |
61 | | - |
62 | | - build: |
63 | | - name: Build |
64 | | - runs-on: ubuntu-latest |
65 | | - needs: test |
66 | | - |
67 | | - steps: |
68 | | - - name: Checkout code |
69 | | - uses: actions/checkout@v4 |
70 | | - |
71 | | - - name: Setup Node.js |
72 | | - uses: actions/setup-node@v4 |
73 | | - with: |
74 | | - node-version: 20.x |
75 | | - |
76 | | - - name: Install pnpm |
77 | | - uses: pnpm/action-setup@v4 |
78 | | - with: |
79 | | - version: 8 |
80 | | - |
81 | | - - name: Get pnpm store directory |
82 | | - shell: bash |
83 | | - run: | |
84 | | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV |
85 | | -
|
86 | | - - name: Setup pnpm cache |
87 | | - uses: actions/cache@v4 |
88 | | - with: |
89 | | - path: ${{ env.STORE_PATH }} |
90 | | - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
91 | | - restore-keys: | |
92 | | - ${{ runner.os }}-pnpm-store- |
93 | | -
|
94 | | - - name: Install dependencies |
95 | | - run: pnpm install --frozen-lockfile |
96 | | - |
97 | | - - name: Build for production |
98 | | - run: pnpm run build:prod |
99 | | - |
100 | | - - name: Upload build artifacts |
101 | | - uses: actions/upload-artifact@v4 |
102 | | - with: |
103 | | - name: dist |
104 | | - path: dist/ |
105 | | - retention-days: 7 |
| 10 | + test: |
| 11 | + name: Test and Lint |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + strategy: |
| 15 | + matrix: |
| 16 | + node-version: [20.x] |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout code |
| 20 | + uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: Install pnpm |
| 23 | + uses: pnpm/action-setup@v4 |
| 24 | + with: |
| 25 | + version: 8 |
| 26 | + |
| 27 | + - name: Setup Node.js ${{ matrix.node-version }} |
| 28 | + uses: actions/setup-node@v4 |
| 29 | + with: |
| 30 | + node-version: ${{ matrix.node-version }} |
| 31 | + cache: "pnpm" |
| 32 | + |
| 33 | + - name: Get pnpm store directory |
| 34 | + shell: bash |
| 35 | + run: | |
| 36 | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV |
| 37 | +
|
| 38 | + - name: Setup pnpm cache |
| 39 | + uses: actions/cache@v4 |
| 40 | + with: |
| 41 | + path: ${{ env.STORE_PATH }} |
| 42 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 43 | + restore-keys: | |
| 44 | + ${{ runner.os }}-pnpm-store- |
| 45 | +
|
| 46 | + - name: Install dependencies |
| 47 | + run: pnpm install --frozen-lockfile |
| 48 | + |
| 49 | + - name: Check formatting |
| 50 | + run: pnpm run format:check |
| 51 | + |
| 52 | + - name: Run linter |
| 53 | + run: pnpm run lint |
| 54 | + |
| 55 | + - name: Type check |
| 56 | + run: pnpm run check |
| 57 | + |
| 58 | + - name: Run tests |
| 59 | + run: pnpm run test |
| 60 | + env: |
| 61 | + NODE_ENV: test |
| 62 | + |
| 63 | + - name: Build project |
| 64 | + run: pnpm run build |
| 65 | + |
| 66 | + build: |
| 67 | + name: Build |
| 68 | + runs-on: ubuntu-latest |
| 69 | + needs: test |
| 70 | + |
| 71 | + steps: |
| 72 | + - name: Checkout code |
| 73 | + uses: actions/checkout@v4 |
| 74 | + |
| 75 | + - name: Install pnpm |
| 76 | + uses: pnpm/action-setup@v4 |
| 77 | + with: |
| 78 | + version: 8 |
| 79 | + |
| 80 | + - name: Setup Node.js |
| 81 | + uses: actions/setup-node@v4 |
| 82 | + with: |
| 83 | + node-version: 20.x |
| 84 | + cache: "pnpm" |
| 85 | + |
| 86 | + - name: Get pnpm store directory |
| 87 | + shell: bash |
| 88 | + run: | |
| 89 | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV |
| 90 | +
|
| 91 | + - name: Setup pnpm cache |
| 92 | + uses: actions/cache@v4 |
| 93 | + with: |
| 94 | + path: ${{ env.STORE_PATH }} |
| 95 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 96 | + restore-keys: | |
| 97 | + ${{ runner.os }}-pnpm-store- |
| 98 | +
|
| 99 | + - name: Install dependencies |
| 100 | + run: pnpm install --frozen-lockfile |
| 101 | + |
| 102 | + - name: Prepare for build |
| 103 | + run: pnpm run prebuild |
| 104 | + |
| 105 | + - name: Build for production |
| 106 | + run: pnpm run build:prod |
| 107 | + |
| 108 | + - name: Upload build artifacts |
| 109 | + uses: actions/upload-artifact@v4 |
| 110 | + with: |
| 111 | + name: dist |
| 112 | + path: dist/ |
| 113 | + retention-days: 7 |
| 114 | + |
| 115 | + docker: |
| 116 | + name: Docker build |
| 117 | + runs-on: ubuntu-latest |
| 118 | + needs: test |
| 119 | + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') |
| 120 | + steps: |
| 121 | + - name: Checkout code |
| 122 | + uses: actions/checkout@v4 |
| 123 | + |
| 124 | + - name: Set up Docker Buildx |
| 125 | + uses: docker/setup-buildx-action@v3 |
| 126 | + |
| 127 | + - name: Build Docker image |
| 128 | + uses: docker/build-push-action@v6 |
| 129 | + with: |
| 130 | + context: . |
| 131 | + push: false |
| 132 | + load: true |
| 133 | + tags: museum-management-rest-api:latest |
| 134 | + cache-from: type=gha |
| 135 | + cache-to: type=gha,mode=max |
0 commit comments