Skip to content

Commit 7a0b957

Browse files
authored
Merge pull request #116 from CleanEngine/config/ci-cd
Config/ci cd
2 parents dc59122 + f57e687 commit 7a0b957

5 files changed

Lines changed: 48 additions & 98 deletions

File tree

.github/workflows/code-analyze-push.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.

.github/workflows/code-analyze-pr.yml renamed to .github/workflows/code-analyze-sonarqube.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,52 @@
1-
name: Code Analyze Pull Request
1+
name: Code Analyze With SonarQube
22

3-
run-name: Run code analyze triggered with pull request by ${{github.actor}}
3+
run-name: Run code analyze triggered by ${{github.actor}}
44

55
on:
66
pull_request:
77
types: [opened, reopened, synchronize]
88
branches:
99
- main
1010
- dev
11+
paths:
12+
- 'src/**'
13+
push:
14+
branches:
15+
- dev
16+
paths:
17+
- 'src/**'
1118

1219
jobs:
1320
build:
1421
name: Build and analyze
1522
runs-on: ubuntu-latest
1623

1724
steps:
18-
- uses: actions/checkout@v4
25+
- name: Checkout code
26+
uses: actions/checkout@v4
1927
with:
2028
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
29+
2130
- name: Set up JDK 21
2231
uses: actions/setup-java@v4
2332
with:
2433
java-version: 21
25-
distribution: 'temurin' # Alternative distribution options are available.
34+
distribution: 'temurin'
35+
2636
- name: Cache SonarQube packages
2737
uses: actions/cache@v4
2838
with:
2939
path: ~/.sonar/cache
3040
key: ${{ runner.os }}-sonar
3141
restore-keys: ${{ runner.os }}-sonar
42+
3243
- name: Cache Gradle packages
3344
uses: actions/cache@v4
3445
with:
3546
path: ~/.gradle/caches
3647
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
3748
restore-keys: ${{ runner.os }}-gradle
49+
3850
- name: Build with tests
3951
env:
4052
JWT_SECRET: ${{ secrets.JWT_SECRET }}

.github/workflows/deploy.yml

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
name: CI/CD Deploy
1+
name: CI/CD Deploy and Start services
22

3-
run-name: Deploy springboot as backend image to ECR by ${{github.actor}}
3+
run-name: Deploy to ECR and Start services by ${{github.actor}}
44

55
on:
66
push:
7-
branches: [ "main" ]
8-
paths-ignore:
9-
- 'README.md'
10-
- '.gitignore'
7+
branches:
8+
- main
9+
paths:
10+
- 'src/**'
1111

1212
jobs:
1313
build:
@@ -32,20 +32,31 @@ jobs:
3232
- name: Build with Gradle Wrapper
3333
run: ./gradlew build -x test
3434

35-
- name: Build image
36-
run: |
37-
docker build -t ${{ secrets.AWS_ORGANIZATION }}/backend .
38-
docker tag ${{ secrets.AWS_ORGANIZATION }}/backend:latest ${{ secrets.AWS_ECR_BACKEND_REPO }}:latest
39-
40-
- name: Configure AWS credentials
41-
uses: aws-actions/configure-aws-credentials@v4
35+
- name: Login to DockerHub
36+
uses: docker/login-action@v3
4237
with:
43-
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
44-
aws-region: ${{ secrets.AWS_REGION }}
38+
username: ${{secrets.DOCKER_USERNAME}}
39+
password: ${{secrets.DOCKER_TOKEN}}
4540

46-
- name: Login to Amazon ECR
47-
uses: aws-actions/amazon-ecr-login@v2
41+
- name: Build and Push Docker Image
42+
uses: docker/build-push-action@v5
43+
with:
44+
context: .
45+
file: ./Dockerfile
46+
push: true
47+
tags: ${{secrets.DOCKER_USERNAME}}/if-be:latest
4848

49-
- name: Push image to ECR
50-
run: |
51-
docker push ${{ secrets.AWS_ECR_BACKEND_REPO }}:latest
49+
start-services:
50+
needs: build
51+
runs-on: ubuntu-latest
52+
steps:
53+
- name: Connect to cloud server and run Docker commands
54+
uses: appleboy/ssh-action@v1.2.2
55+
with:
56+
host: ${{secrets.BACKEND_HOST}}
57+
username: ${{secrets.CLOUD_USERNAME}}
58+
key: ${{secrets.CLOUD_SECRET_KEY}}
59+
port: ${{secrets.CLOUD_PORT}}
60+
script: |
61+
cd ~
62+
/bin/bash run_springboot.sh

.github/workflows/start-service.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/main/resources/application-prod.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ spring:
33
cookie:
44
secure: true
55
datasource:
6-
url: jdbc:mariadb://mariadb:3306/${MARIADB_DATABASE}
6+
url: jdbc:mariadb://${MARIADB_HOST}:3306/${MARIADB_DATABASE}
77
driver-class-name: org.mariadb.jdbc.Driver
88
username: ${MARIADB_USER}
99
password: ${MARIADB_PASSWORD}

0 commit comments

Comments
 (0)