-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
name: ci/cd | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build-backend: | ||
runs-on: ubuntu-22.04 | ||
defaults: | ||
run: | ||
working-directory: backend | ||
|
||
steps: | ||
- name: Set up Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: "17" | ||
distribution: "corretto" | ||
|
||
- name: Give permission for Gradle | ||
run: chmod +x gradlew | ||
|
||
- name: Cache Gradle | ||
id: cache-gradle | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.gradle/caches | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
- name: Build with Gradle | ||
run: ./gradlew bootJar | ||
|
||
- name: Upload jar file artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: BackendApplicationJar | ||
path: backend/build/libs/*.jar | ||
|
||
build-frontend: | ||
runs-on: ubuntu-22.04 | ||
defaults: | ||
run: | ||
working-directory: frontend | ||
|
||
steps: | ||
- name: Set up Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup node with cache | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: "npm" | ||
cache-dependency-path: "**/package-lock.json" | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Build App | ||
run: npm run build | ||
|
||
- name: Upload frontend build file to artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: FrontendApplication | ||
path: frontend/out | ||
|
||
deploy: | ||
needs: [build-backend, build-frontend] | ||
runs-on: self-hosted | ||
|
||
steps: | ||
- name: Remove previous version FRONT app | ||
working-directory: frontend/prod/ | ||
run: rm -rf dist | ||
|
||
- name: Download FRONT build file from artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: FrontendApplication | ||
path: frontend/prod/ | ||
|
||
- name: Remove previous version BACK jar | ||
working-directory: backend/prod/ | ||
run: rm -f *.jar | ||
|
||
- name: Download BACK jar file from artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: BackendApplicationJar | ||
path: backend/prod/ | ||
|
||
- name: Deploy BACK to production server | ||
working-directory: backend/prod/ | ||
run: ./start.sh |