|
1 | | -name: CI |
2 | | -on: |
3 | | - pull_request: |
4 | | - types: [opened, edited, synchronize, reopened, ready_for_review] |
5 | | - branches: |
6 | | - - main |
7 | | - push: |
8 | | - branches: |
9 | | - - main |
10 | | - |
11 | | -jobs: |
12 | | - setup: |
13 | | - name: Setup |
14 | | - runs-on: ubuntu-latest |
15 | | - steps: |
16 | | - - uses: actions/checkout@v4 |
17 | | - |
18 | | - - uses: actions/setup-node@v4 |
19 | | - with: |
20 | | - node-version: 22 |
21 | | - |
22 | | - - name: Cache node_modules |
23 | | - uses: actions/cache@v4 |
24 | | - id: npm-cache |
25 | | - with: |
26 | | - key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }} |
27 | | - path: node_modules |
28 | | - |
29 | | - - name: Install dependencies |
30 | | - if: steps.npm-cache.outputs.cache-hit != 'true' |
31 | | - run: npm ci |
32 | | - |
33 | | - - name: Lint code |
34 | | - run: npm run lint |
35 | | - |
36 | | - - name: Type-check |
37 | | - run: npm run type-check |
38 | | - |
39 | | - build-preview: |
40 | | - name: Build Preview |
41 | | - if: contains(github.ref, 'refs/heads/main') != true |
42 | | - needs: [setup] |
43 | | - runs-on: ubuntu-latest |
44 | | - env: |
45 | | - alias: preview-pr-${{ github.event.pull_request.number }} |
46 | | - NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} |
47 | | - NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} |
48 | | - environment: |
49 | | - name: preview-pr-${{ github.event.pull_request.number }} |
50 | | - url: ${{ steps.netlify.outputs.deploy-url }} |
51 | | - steps: |
52 | | - - uses: actions/checkout@v4 |
53 | | - |
54 | | - - uses: actions/setup-node@v4 |
55 | | - with: |
56 | | - node-version: 22 |
57 | | - |
58 | | - - name: Cache node_modules |
59 | | - uses: actions/cache@v4 |
60 | | - id: npm-cache |
61 | | - with: |
62 | | - key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }} |
63 | | - path: node_modules |
64 | | - |
65 | | - - name: Install dependencies |
66 | | - if: steps.npm-cache.outputs.cache-hit != 'true' |
67 | | - run: npm ci |
68 | | - |
69 | | - - name: cache build |
70 | | - uses: actions/cache@v4 |
71 | | - id: build-cache |
72 | | - with: |
73 | | - key: ${{ runner.os }}-build-${{ hashFiles('src', 'dist', 'package-lock') }} |
74 | | - path: dist |
75 | | - |
76 | | - - name: build |
77 | | - if: steps.build-cache.outputs.cache-hit != 'true' |
78 | | - run: npm run build |
79 | | - |
80 | | - - name: Deploy preview on netlify |
81 | | - id: netlify |
82 | | - run: | |
83 | | - npx netlify deploy --dir=dist --alias=${{ env.alias }} --message "Preview deploy PR_${{ github.event.pull_request.number }} - ${{ github.event.pull_request.title }}" |
84 | | - echo "::set-output name=deploy-url::https://${{ env.alias }}--gcstatus.netlify.app" |
85 | | -
|
86 | | - unit-tests: |
87 | | - name: Unit tests and Coverage |
88 | | - runs-on: ubuntu-latest |
89 | | - needs: [setup] |
90 | | - steps: |
91 | | - - uses: actions/checkout@v4 |
92 | | - |
93 | | - - uses: actions/setup-node@v4 |
94 | | - with: |
95 | | - node-version: 22 |
96 | | - |
97 | | - - name: Cache node_modules |
98 | | - uses: actions/cache@v4 |
99 | | - id: npm-cache |
100 | | - with: |
101 | | - key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }} |
102 | | - path: node_modules |
103 | | - |
104 | | - - name: Install dependencies |
105 | | - if: steps.npm-cache.outputs.cache-hit != 'true' |
106 | | - run: npm ci |
107 | | - |
108 | | - - name: Run unit tests |
109 | | - run: npm run test:ci |
110 | | - |
111 | | - - name: Upload coverage to Codecov |
112 | | - uses: codecov/codecov-action@v4 |
113 | | - with: |
114 | | - token: ${{ secrets.CODECOV_TOKEN }} |
115 | | - |
116 | | - deploy-staging: |
117 | | - name: Deploy staging environment |
118 | | - runs-on: ubuntu-latest |
119 | | - if: contains(github.ref, 'refs/heads/main') |
120 | | - environment: |
121 | | - name: staging |
122 | | - url: https://staging--gcstatus.netlify-app |
123 | | - env: |
124 | | - NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} |
125 | | - NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} |
126 | | - needs: [unit-tests] |
127 | | - steps: |
128 | | - - uses: actions/checkout@v4 |
129 | | - |
130 | | - - uses: actions/setup-node@v4 |
131 | | - with: |
132 | | - node-version: 22 |
133 | | - |
134 | | - - name: Cache node_modules |
135 | | - uses: actions/cache@v4 |
136 | | - id: npm-cache |
137 | | - with: |
138 | | - key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }} |
139 | | - path: node_modules |
140 | | - |
141 | | - - name: Install dependencies |
142 | | - if: steps.npm-cache.outputs.cache-hit != 'true' |
143 | | - run: npm ci |
144 | | - |
145 | | - - name: build |
146 | | - run: npm run build |
147 | | - |
148 | | - - name: Deploy on staging |
149 | | - run: npx netlify deploy --dir=dist --alias=staging --message "Staging deploy" |
150 | | - |
151 | | - deploy-release: |
152 | | - name: Deploy and Release |
153 | | - runs-on: ubuntu-latest |
154 | | - environment: |
155 | | - name: production |
156 | | - url: https://gcstatus.netlify.app |
157 | | - needs: [deploy-staging] |
158 | | - if: contains(github.ref, 'refs/heads/main') |
159 | | - env: |
160 | | - NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} |
161 | | - NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} |
162 | | - VITE_BASE_URL: ${{ secrets.VITE_BASE_URL }} |
163 | | - steps: |
164 | | - - uses: actions/checkout@v4 |
165 | | - |
166 | | - - uses: actions/setup-node@v4 |
167 | | - with: |
168 | | - node-version: 22 |
169 | | - |
170 | | - - name: Cache node_modules |
171 | | - uses: actions/cache@v4 |
172 | | - id: npm-cache |
173 | | - with: |
174 | | - key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }} |
175 | | - path: node_modules |
176 | | - |
177 | | - - name: Install dependencies |
178 | | - if: steps.npm-cache.outputs.cache-hit != 'true' |
179 | | - run: npm ci |
180 | | - |
181 | | - - name: build |
182 | | - run: npm run build |
183 | | - |
184 | | - - name: Deploy on production |
185 | | - run: npx netlify deploy --dir=dist --prod --message "Production deploy" |
186 | | - |
187 | | - # - name: Generate release |
188 | | - # run: npm run semantic-release |
189 | | - # env: |
190 | | - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
191 | | - |
192 | | - all_required_checks_passed: |
193 | | - name: All required checks passed |
194 | | - runs-on: ubuntu-latest |
195 | | - needs: [unit-tests, build-preview] |
196 | | - if: contains(github.ref, 'refs/heads/main') != true |
197 | | - steps: |
198 | | - - name: Mark PR as ready to merge |
199 | | - run: exit 0 |
| 1 | +name: CI |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + types: [opened, edited, synchronize, reopened, ready_for_review] |
| 5 | + branches: |
| 6 | + - main |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + |
| 11 | +jobs: |
| 12 | + setup: |
| 13 | + name: Setup |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - uses: actions/setup-node@v4 |
| 19 | + with: |
| 20 | + node-version: 22 |
| 21 | + |
| 22 | + - name: Cache node_modules |
| 23 | + uses: actions/cache@v4 |
| 24 | + id: npm-cache |
| 25 | + with: |
| 26 | + key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }} |
| 27 | + path: node_modules |
| 28 | + |
| 29 | + - name: Install dependencies |
| 30 | + if: steps.npm-cache.outputs.cache-hit != 'true' |
| 31 | + run: npm i |
| 32 | + |
| 33 | + - name: Lint code |
| 34 | + run: npm run lint |
| 35 | + |
| 36 | + - name: Type-check |
| 37 | + run: npm run type-check |
| 38 | + |
| 39 | + build-preview: |
| 40 | + name: Build Preview |
| 41 | + if: contains(github.ref, 'refs/heads/main') != true |
| 42 | + needs: [setup] |
| 43 | + runs-on: ubuntu-latest |
| 44 | + env: |
| 45 | + alias: preview-pr-${{ github.event.pull_request.number }} |
| 46 | + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} |
| 47 | + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} |
| 48 | + environment: |
| 49 | + name: preview-pr-${{ github.event.pull_request.number }} |
| 50 | + url: ${{ steps.netlify.outputs.deploy-url }} |
| 51 | + steps: |
| 52 | + - uses: actions/checkout@v4 |
| 53 | + |
| 54 | + - uses: actions/setup-node@v4 |
| 55 | + with: |
| 56 | + node-version: 22 |
| 57 | + |
| 58 | + - name: Cache node_modules |
| 59 | + uses: actions/cache@v4 |
| 60 | + id: npm-cache |
| 61 | + with: |
| 62 | + key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }} |
| 63 | + path: node_modules |
| 64 | + |
| 65 | + - name: Install dependencies |
| 66 | + if: steps.npm-cache.outputs.cache-hit != 'true' |
| 67 | + run: npm ci |
| 68 | + |
| 69 | + - name: cache build |
| 70 | + uses: actions/cache@v4 |
| 71 | + id: build-cache |
| 72 | + with: |
| 73 | + key: ${{ runner.os }}-build-${{ hashFiles('src', 'dist', 'package-lock') }} |
| 74 | + path: dist |
| 75 | + |
| 76 | + - name: build |
| 77 | + if: steps.build-cache.outputs.cache-hit != 'true' |
| 78 | + run: npm run build |
| 79 | + |
| 80 | + - name: Deploy preview on netlify |
| 81 | + id: netlify |
| 82 | + run: | |
| 83 | + npx netlify deploy --dir=dist --alias=${{ env.alias }} --message "Preview deploy PR_${{ github.event.pull_request.number }} - ${{ github.event.pull_request.title }}" |
| 84 | + echo "::set-output name=deploy-url::https://${{ env.alias }}--gcstatus.netlify.app" |
| 85 | +
|
| 86 | + unit-tests: |
| 87 | + name: Unit tests and Coverage |
| 88 | + runs-on: ubuntu-latest |
| 89 | + needs: [setup] |
| 90 | + steps: |
| 91 | + - uses: actions/checkout@v4 |
| 92 | + |
| 93 | + - uses: actions/setup-node@v4 |
| 94 | + with: |
| 95 | + node-version: 22 |
| 96 | + |
| 97 | + - name: Cache node_modules |
| 98 | + uses: actions/cache@v4 |
| 99 | + id: npm-cache |
| 100 | + with: |
| 101 | + key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }} |
| 102 | + path: node_modules |
| 103 | + |
| 104 | + - name: Install dependencies |
| 105 | + if: steps.npm-cache.outputs.cache-hit != 'true' |
| 106 | + run: npm ci |
| 107 | + |
| 108 | + - name: Run unit tests |
| 109 | + run: npm run test:ci |
| 110 | + |
| 111 | + - name: Upload coverage to Codecov |
| 112 | + uses: codecov/codecov-action@v4 |
| 113 | + with: |
| 114 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 115 | + |
| 116 | + deploy-staging: |
| 117 | + name: Deploy staging environment |
| 118 | + runs-on: ubuntu-latest |
| 119 | + if: contains(github.ref, 'refs/heads/main') |
| 120 | + environment: |
| 121 | + name: staging |
| 122 | + url: https://staging--gcstatus.netlify-app |
| 123 | + env: |
| 124 | + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} |
| 125 | + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} |
| 126 | + needs: [unit-tests] |
| 127 | + steps: |
| 128 | + - uses: actions/checkout@v4 |
| 129 | + |
| 130 | + - uses: actions/setup-node@v4 |
| 131 | + with: |
| 132 | + node-version: 22 |
| 133 | + |
| 134 | + - name: Cache node_modules |
| 135 | + uses: actions/cache@v4 |
| 136 | + id: npm-cache |
| 137 | + with: |
| 138 | + key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }} |
| 139 | + path: node_modules |
| 140 | + |
| 141 | + - name: Install dependencies |
| 142 | + if: steps.npm-cache.outputs.cache-hit != 'true' |
| 143 | + run: npm ci |
| 144 | + |
| 145 | + - name: build |
| 146 | + run: npm run build |
| 147 | + |
| 148 | + - name: Deploy on staging |
| 149 | + run: npx netlify deploy --dir=dist --alias=staging --message "Staging deploy" |
| 150 | + |
| 151 | + deploy-release: |
| 152 | + name: Deploy and Release |
| 153 | + runs-on: ubuntu-latest |
| 154 | + environment: |
| 155 | + name: production |
| 156 | + url: https://gcstatus.netlify.app |
| 157 | + needs: [deploy-staging] |
| 158 | + if: contains(github.ref, 'refs/heads/main') |
| 159 | + env: |
| 160 | + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} |
| 161 | + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} |
| 162 | + VITE_BASE_URL: ${{ secrets.VITE_BASE_URL }} |
| 163 | + steps: |
| 164 | + - uses: actions/checkout@v4 |
| 165 | + |
| 166 | + - uses: actions/setup-node@v4 |
| 167 | + with: |
| 168 | + node-version: 22 |
| 169 | + |
| 170 | + - name: Cache node_modules |
| 171 | + uses: actions/cache@v4 |
| 172 | + id: npm-cache |
| 173 | + with: |
| 174 | + key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }} |
| 175 | + path: node_modules |
| 176 | + |
| 177 | + - name: Install dependencies |
| 178 | + if: steps.npm-cache.outputs.cache-hit != 'true' |
| 179 | + run: npm ci |
| 180 | + |
| 181 | + - name: build |
| 182 | + run: npm run build |
| 183 | + |
| 184 | + - name: Deploy on production |
| 185 | + run: npx netlify deploy --dir=dist --prod --message "Production deploy" |
| 186 | + |
| 187 | + # - name: Generate release |
| 188 | + # run: npm run semantic-release |
| 189 | + # env: |
| 190 | + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 191 | + |
| 192 | + all_required_checks_passed: |
| 193 | + name: All required checks passed |
| 194 | + runs-on: ubuntu-latest |
| 195 | + needs: [unit-tests, build-preview] |
| 196 | + if: contains(github.ref, 'refs/heads/main') != true |
| 197 | + steps: |
| 198 | + - name: Mark PR as ready to merge |
| 199 | + run: exit 0 |
0 commit comments