-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (67 loc) · 2.07 KB
/
master-build.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
#Workflow name
name: Master CI/CD Pipeline
on:
#Manually trigger workflow runs
workflow_dispatch:
#Trigger the workflow on push from the main branch
push:
branches:
- master
jobs:
#Test's job
tests:
name: Unit tests
#Run on Ubuntu using the latest version
runs-on: ubuntu-latest
env:
ENV: "prod"
#Job's steps
steps:
#Check-out your repository under $GITHUB_WORKSPACE, so your workflow can access it
- name: Checkout Code
uses: actions/checkout@v3
- name: Create env file
run: |
echo "${{ env.ENV_FILE }}" > .env
source .env
# Start MongoDB
- name: Start MongoDB
uses: supercharge/[email protected]
with:
mongodb-replica-set: test-rs
mongodb-port: 27017
mongodb-username: test
mongodb-password: 123456
mongodb-db: network
#Set up JDK 17
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: '17'
#Set up Maven cache
- name: Cache Maven packages
#This action allows caching dependencies and build outputs to improve workflow execution time.
uses: actions/cache@v1
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
# #Migrate Database
# - name: Migrate Database
# run: mvn flyway:migrate
#Run Tests
- name: Run Tests
run: mvn -B test
# Pack Application
- name: build mvn package
run: mvn clean package
# Build Docker Image
- name: DockerHub Login
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build the Docker image
run: docker build . --file Dockerfile --tag ${{ secrets.DOCKERHUB_USERNAME }}/iptable_controller_backend:latest
- name: Docker Push
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/iptable_controller_backend