https://dev.kronoz.win/r/marzneshin.git
1name: Dashboard CI
2
3on:
4 push:
5 branches: [ "master" ]
6 paths:
7 - "dashboard/**"
8 pull_request:
9 branches: [ "master" ]
10 paths:
11 - "dashboard/**"
12
13jobs:
14 lint:
15 env:
16 VITE_BASE_API: /api/
17 runs-on: ubuntu-latest
18 defaults:
19 run:
20 working-directory: ./dashboard
21 steps:
22 - uses: actions/checkout@v4
23
24 - uses: pnpm/action-setup@v3
25 name: Install pnpm
26 with:
27 version: 8
28 run_install: false
29 - name: Get pnpm store directory
30 shell: bash
31 run: |
32 echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
33
34 - uses: actions/cache@v3
35 name: Setup pnpm cache
36 with:
37 path: ${{ env.STORE_PATH }}
38 key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
39 restore-keys: |
40 ${{ runner.os }}-pnpm-store-
41
42 - name: 📥 Install deps
43 run: pnpm install
44
45 - name: Lint Dashboard
46 run: pnpm lint
47
48 build:
49 needs: [ lint ]
50 env:
51 VITE_BASE_API: /api/
52 runs-on: ubuntu-latest
53 defaults:
54 run:
55 working-directory: ./dashboard
56 steps:
57 - uses: actions/checkout@v4
58 with:
59 fetch-depth: '0'
60
61 - uses: pnpm/action-setup@v3
62 name: Install pnpm
63 with:
64 version: 8
65 run_install: false
66 - name: Get pnpm store directory
67 shell: bash
68 run: |
69 echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
70
71 - uses: actions/cache@v3
72 name: Setup pnpm cache
73 with:
74 path: ${{ env.STORE_PATH }}
75 key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
76 restore-keys: |
77 ${{ runner.os }}-pnpm-store-
78
79 - name: 📥 Install deps
80 run: pnpm install
81
82 - name: Set Git version for PRs
83 if: github.event_name == 'pull_request'
84 id: get_version_pr
85 run: |
86 LATEST_TAG=${{ github.ref_name }}
87 LATEST_COMMIT=${{ github.sha }}
88 echo "VITE_LATEST_APP_VERSION=${LATEST_TAG}-${LATEST_COMMIT:0:7}" >> $GITHUB_ENV
89
90 - name: Set Git version for main branch
91 if: github.event_name == 'push' && github.ref == 'refs/heads/main'
92 id: get_version_main
93 run: |
94 LATEST_TAG=${{ github.ref_name }}
95 echo "VITE_LATEST_APP_VERSION=${LATEST_TAG}" >> $GITHUB_ENV
96
97 - name: Build Dashboard
98 run: pnpm build --base '/dashboard/'
99
100 - name: Upload a Build Artifact
101 uses: actions/upload-artifact@v4.2.0
102 with:
103 name: artifact
104 path: dashboard/dist
105
106 unit-test:
107 needs: [ lint, build ]
108 env:
109 VITE_BASE_API: /api/
110 runs-on: ubuntu-latest
111 defaults:
112 run:
113 working-directory: ./dashboard
114 steps:
115 - uses: actions/checkout@v4
116
117 - uses: pnpm/action-setup@v3
118 name: Install pnpm
119 with:
120 version: 8
121 run_install: false
122 - name: Get pnpm store directory
123 shell: bash
124 run: |
125 echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
126
127 - uses: actions/cache@v3
128 name: Setup pnpm cache
129 with:
130 path: ${{ env.STORE_PATH }}
131 key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
132 restore-keys: |
133 ${{ runner.os }}-pnpm-store-
134
135 - name: 📥 Install deps
136 run: pnpm install
137
138 - name: Build Dashboard
139 run: pnpm test