-
Notifications
You must be signed in to change notification settings - Fork 1
113 lines (90 loc) · 3.41 KB
/
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
108
109
110
111
112
113
name: Run Tests
on: [pull_request]
jobs:
backend-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up JDK 21
uses: actions/setup-java@v2
with:
java-version: "21"
distribution: "adopt"
- name: Cache Gradle packages
uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Run backend tests
run: cd api && ./gradlew runTestsWithCoverage
frontend-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: "18"
- name: Cache Node.js modules
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-node
- name: Install Dependencies
run: cd frontend && npm install
- name: Run frontend tests
run: cd frontend && npm run test
backend-build-and-deploy-multi-arch:
runs-on: ubuntu-latest # Use an Ubuntu runner
steps:
# Checkout the repository to access the Dockerfile and source code
- name: Checkout code
uses: actions/checkout@v3
# Set up Docker Buildx (needed for multi-platform builds)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# Log in to DockerHub using secrets (replace with your DockerHub credentials)
- name: Log in to DockerHub
uses: docker/login-action@v2
with:
username: "fit3162"
password: 'Gzg[8s!xS=w"<W7;ag3A'
# Build and push the Docker image for multiple platforms (AMD64, ARM)
- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
context: ./api # The root directory, assuming your Dockerfile is here
platforms: linux/amd64,linux/arm64 # Build for AMD64 and ARM64
push: true # Push the image to DockerHub after building
tags: |
fit3162/backend:latest
fit3162/backend:${{ github.sha }}
frontend-build-and-deploy-multi-arch:
runs-on: ubuntu-latest # Use an Ubuntu runner
steps:
# Checkout the repository to access the Dockerfile and source code
- name: Checkout code
uses: actions/checkout@v3
# Set up Docker Buildx (needed for multi-platform builds)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# Log in to DockerHub using secrets (replace with your DockerHub credentials)
- name: Log in to DockerHub
uses: docker/login-action@v2
with:
username: "fit3162"
password: 'Gzg[8s!xS=w"<W7;ag3A'
# Build and push the Docker image for multiple platforms (AMD64, ARM)
- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
context: ./frontend # The root directory, assuming your Dockerfile is here
platforms: linux/amd64,linux/arm64 # Build for AMD64 and ARM64
push: true # Push the image to DockerHub after building
tags: |
fit3162/frontend:latest
fit3162/frontend:${{ github.sha }}