-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (94 loc) · 3.04 KB
/
frontend-ci.yml
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: frontend CI
permissions:
pull-requests: write
contents: read
on:
pull_request:
branches: [main]
paths:
- "front/src/**"
- "backend/src/**"
jobs:
path_changes:
runs-on: ubuntu-latest
outputs:
front: ${{ steps.filter.outputs.front }}
backend: ${{ steps.filter.outputs.backend }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
front:
- 'front/src/**'
backend:
- 'backend/src/**'
frontend-tests:
needs: path_changes
if: needs.path_changes.outputs.front == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Cache Node.js modules
uses: actions/cache@v4
with:
path: front/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/front/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install frontend dependencies
working-directory: front
run: npm install
- name: Run frontend tests
working-directory: front
run: npm test
build_and_push_frontend:
needs: frontend-tests
if: needs.path_changes.outputs.front == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN_FRONTEND }}
- name: Set up Docker Meta for Frontend
id: docker_meta_frontend
uses: docker/metadata-action@v5
with:
images: ${{ secrets.FRONT_DOCKER_IMAGE }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=ref,event=branch
type=ref,event=pr
type=sha
flavor: |
latest=true
- name: Build and Push Frontend Docker Image
uses: docker/build-push-action@v5
with:
context: ./front
file: ./front/Dockerfile
platforms: linux/amd64
push: true
tags: ${{ steps.docker_meta_frontend.outputs.tags }}
labels: ${{ steps.docker_meta_frontend.outputs.labels }}
no-cache: true
build-args: |
NEXT_PUBLIC_DEV_API_URL=${{ secrets.NEXT_PUBLIC_DEV_API_URL }}
NEXT_PUBLIC_PRODUCTION_API_URL=${{ secrets.NEXT_PUBLIC_PRODUCTION_API_URL }}
NEXT_PUBLIC_FRONT_ENV_MODE=${{ secrets.NEXT_PUBLIC_FRONT_ENV_MODE }}
NEXT_PUBLIC_CDN_URL=${{ secrets.NEXT_PUBLIC_CDN_URL }}
SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
NEXT_PUBLIC_SENTRY_DSN=${{ secrets.NEXT_PUBLIC_SENTRY_DSN }}