Skip to content

Commit

Permalink
Action test
Browse files Browse the repository at this point in the history
  • Loading branch information
SalkCoding committed Dec 12, 2024
1 parent a73fa03 commit 31b0e3d
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 18 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/CD.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: CD

on:
push:
branches: [ "cd" ]
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'

- name: Gradle Caching
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Create application.yml
run: |
cd ./src/main/resources
touch ./application.yml
echo "${{ secrets.APPLICATION }}" > ./application.yml
shell: bash

- name: Access permission to gradle build
run: chmod +x gradlew

- name: Run gradle build
run: ./gradlew build
shell: bash

- name: Build docker image build and push
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -t ${{ secrets.DOCKER_REPOSITORY }}/${{ secrets.DOCKER_IMAGE }} .
docker push ${{ secrets.DOCKER_REPOSITORY }}/${{ secrets.DOCKER_IMAGE }}
- name: Pull from docker hub and deploy
uses: appleboy/ssh-action@master
with:
username: ${{ REMOTE_USERNAME }}
host: ${{ secrets.REMOTE_HOST }}
key: ${{ secrets.REMOTE_KEY }}
script: |
cd /Backend
sudo docker compose down
sudo docker compose up -d
44 changes: 38 additions & 6 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,46 @@
services:
backend:
image: ${DOCKER_BACKEND_IMAGE}
environment:
SPRING_DATASOURCE_URL: ${SPRING_DATASOURCE_URL}
SPRING_DATASOURCE_USERNAME: ${SPRING_DATASOURCE_USERNAME}
SPRING_DATASOURCE_PASSWORD: ${SPRING_DATASOURCE_PASSWORD}
SPRING_DATA_REDIS_HOST: ${SPRING_DATA_REDIS_HOST}
SPRING_DATA_REDIS_PORT: ${SPRING_DATA_REDIS_PORT}
SPRING_DATA_REDIS_CLIENT_NAME: ${SPRING_DATA_REDIS_CLIENT_NAME}
SPRING_DATA_REDIS_PASSWORD: ${SPRING_DATA_REDIS_PASSWORD}
ports:
- '8080:8080'
depends_on:
- mysql
- redis
networks:
- db

mysql:
image: 'mysql:latest'
environment:
- 'MYSQL_DATABASE=mydatabase'
- 'MYSQL_PASSWORD=secret'
- 'MYSQL_ROOT_PASSWORD=verysecret'
- 'MYSQL_USER=myuser'
MYSQL_DATABASE: ${}
MYSQL_ROOT_PASSWORD: salk1104-
volumes:
- mysql_data:/var/lib/mysql
ports:
- '3306'
- '3306:3306'
networks:
- db

redis:
image: 'redis:latest'
ports:
- '6379'
- '6379:6379'
volumes:
- redis_data:/usr/local/etc/redis
networks:
- db

networks:
db:

volumes:
mysql_data:
redis_data:
13 changes: 1 addition & 12 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ spring:
name: OhLottery

datasource:
url: jdbc:mysql://localhost:3306/ohlottery
username: root
password: kimhy119@
driver-class-name: com.mysql.cj.jdbc.Driver

jpa:
Expand All @@ -15,11 +12,7 @@ spring:
session:
store-type: redis
redis:
namespace: spring:ohlottery
host: localhost
port: 6379
client-name: root
password:
namespace: ohlottery:session

springdoc:
swagger-ui:
Expand All @@ -40,7 +33,3 @@ server:
same-site: none
secure: true
tracking-modes: cookie

redis:
host: localhost
port: 6379

0 comments on commit 31b0e3d

Please sign in to comment.