-
Notifications
You must be signed in to change notification settings - Fork 0
124 lines (116 loc) · 4.25 KB
/
Copy pathgradle.yml
File metadata and controls
124 lines (116 loc) · 4.25 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: Dutypark CI/CD
on:
push:
branches: [ "main", "stage" ]
pull_request:
branches: [ "main", "stage" ]
types: [ opened, synchronize, reopened, ready_for_review ]
permissions:
contents: read
jobs:
release-note:
if: github.event_name == 'pull_request' && github.base_ref == 'main' && github.event.pull_request.draft == false && github.event.pull_request.user.login != 'dependabot[bot]' && !startsWith(github.event.pull_request.head.ref, 'dependabot/')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Check PR release note entry
run: node .github/scripts/check-pr-release-note.mjs "${{ github.event.pull_request.number }}"
- name: Install frontend dependencies
run: npm ci
working-directory: frontend
- name: Validate release notes
run: npm run release-notes:check
working-directory: frontend
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
# Backend build
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'
- name: Build backend with Gradle
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: build
# Frontend build
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install frontend dependencies
run: npm ci
working-directory: frontend
- name: Type check frontend
run: npm run type-check
working-directory: frontend
- name: Build frontend
run: npm run build
working-directory: frontend
# Upload artifacts
- name: Upload backend artifact
uses: actions/upload-artifact@v4
with:
name: backend-jar
path: build/libs/*.jar
- name: Upload frontend artifact
uses: actions/upload-artifact@v4
with:
name: frontend-dist
path: frontend/dist
deploy:
needs: build
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/stage')
runs-on: ubuntu-latest
steps:
- name: Download backend artifact
uses: actions/download-artifact@v4
with:
name: backend-jar
path: backend
- name: Download frontend artifact
uses: actions/download-artifact@v4
with:
name: frontend-dist
path: frontend-dist
- name: Setup SSH
uses: webfactory/ssh-agent@v0.5.4
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Add remote server to known hosts
run: |
mkdir -p ~/.ssh
ssh-keyscan -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_IP }} >> ~/.ssh/known_hosts
- name: Deploy backend JAR
run: scp -P ${{ secrets.SSH_PORT }} backend/*.jar ${{ secrets.SSH_USER }}@${{ secrets.SSH_IP }}:/dutypark/download.jar
- name: Deploy frontend dist
run: |
ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_IP }} "rm -rf /dutypark/frontend-download && mkdir -p /dutypark/frontend-download"
scp -r -P ${{ secrets.SSH_PORT }} frontend-dist/* ${{ secrets.SSH_USER }}@${{ secrets.SSH_IP }}:/dutypark/frontend-download/
- name: Execute remote commands
run: |
ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_IP }} << 'EOF'
mv /dutypark/download.jar /dutypark/build/libs/dutypark.jar
rm -rf /dutypark/frontend/dist/*
mv /dutypark/frontend-download/* /dutypark/frontend/dist/
docker compose -f /dutypark/docker-compose.yml build app
docker compose -f /dutypark/docker-compose.yml up -d app nginx
EOF