-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (76 loc) · 2.65 KB
/
main.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
name: Deploy Spring Boot App
on:
push:
branches: [ main ]
permissions:
contents: write
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
jobs:
build-and-test-backend:
name: Build and Test Application (Backend)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'
cache: maven
- name: Build and Test Backend
working-directory: ./backend
run: mvn clean verify
- name: Upload JaCoCo Coverage Report (Backend)
uses: actions/upload-artifact@v4
with:
name: jacoco-report-backend
path: |
backend/target/site/jacoco/jacoco.csv
backend/target/site/jacoco/jacoco.xml
backend/target/site/jacoco/index.html
- name: Generate JaCoCo Badge (Backend)
id: generate_badge_backend
uses: cicirello/jacoco-badge-generator@v2
with:
jacoco-csv-file: backend/target/site/jacoco/jacoco.csv
badges-directory: .github/badges
generate-coverage-badge: true
coverage-badge-filename: jacoco.svg
generate-coverage-endpoint: true
coverage-endpoint-filename: jacoco.json
- name: Commit and push badges to badges branch (Backend)
if: ${{ github.event_name != 'pull_request' }}
run: |
git config --global user.name 'github-actions'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
# Create or switch to the badges branch
git checkout -B badges
# Ensure badges directory exists
mkdir -p badges
# Copy generated badge files
cp .github/badges/jacoco.svg badges/
cp .github/badges/jacoco.json badges/
# Stage and commit changes
git add badges/*
git commit -m "Update JaCoCo coverage badges" || echo "No changes to commit"
git push origin badges --force # Push to badges branch
- name: Upload Frontend Build Artifacts
uses: actions/upload-artifact@v4
with:
name: frontend-build
path: frontend/dist/
deploy-backend:
name: Deploy Backend
runs-on: ubuntu-latest
needs: build-and-test-backend
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Fly CLI
uses: superfly/flyctl-actions/setup-flyctl@master
- name: Deploy Spring Boot App
working-directory: ./backend
run: |
flyctl deploy --remote-only