-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (72 loc) · 2.18 KB
/
dev-workflow.yml
File metadata and controls
89 lines (72 loc) · 2.18 KB
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
name: dev-workflow.yml
on:
push:
branches: [main]
tags: ['*']
pull_request:
branches: [main]
jobs:
# ── BACKEND TEST ──
backend-test:
name: Backend Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-java@v5
with:
java-version: '21'
distribution: 'temurin'
cache: 'maven'
- name: Run backend tests
working-directory: projekt/backend
run: ./mvnw clean test
# ── FRONTEND TEST ──
frontend-test:
name: Frontend Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: projekt/frontend/package-lock.json
- name: Install NPM Dependencies
working-directory: projekt/frontend
run: npm ci
- name: Run NPM Tests
working-directory: projekt/frontend
run: npm run test:ci
# ── BUILD & PUSH ──
build-job:
name: Docker Build & Push
runs-on: ubuntu-latest
needs: [backend-test, frontend-test]
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Creating .env file
run: |
echo "JWT_SECRET=${{secrets.JWT_SECRET}}" >> projekt/.env
echo "REFRESH_TOKEN_HMAC_SECRET=${{secrets.REFRESH_TOKEN_SECRET_HMAC}}" >> projekt/.env
- name: Login to Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build & Push via Docker Compose
working-directory: projekt
env:
REGISTRY: ghcr.io/${{ github.repository }}
IMAGE_TAG: ${{ github.sha }}
run: |
docker compose -f docker-compose.dev.yml build
docker compose -f docker-compose.dev.yml push
- name: Cleanup
if: always()
working-directory: projekt
run: docker compose -f docker-compose.dev.yml down