Skip to content

Commit

Permalink
ci: DockerHub 배포 오류를 해결한다.
Browse files Browse the repository at this point in the history
* build 결과물을 토대로 배포를 하도록 Dockerfile이 작성되어 있기 때문에, 프로젝트를 빌드하는 코드를 추가하였다.
  • Loading branch information
megymj committed Jan 3, 2024
1 parent 1812db6 commit 46653b1
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/cd-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,79 @@ jobs:
build:
runs-on: ubuntu-latest

services:
mongodb:
image: mongo:4.4
options: >-
--health-cmd mongo
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 27017:27017

mysql:
image: mysql:8.0
env:
MYSQL_DATABASE: menjil-test
MYSQL_ROOT_PASSWORD: root
# MYSQL_USER: root
# MYSQL_PASSWORD: root33
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
steps:
# workflow 실행 전 기본적으로 checkout 필요
- uses: actions/checkout@v4
- name: Install Ubuntu dependencies
run: sudo apt-get update

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin' # Eclipse Temurin
java-version: '17'

## Create secret yml files before build
- name: create application-common, local, prod, test.yml
shell: bash
run: |
touch ./src/main/resources/application-common.yml
echo "${{secrets.APPLICATION_COMMON}}" > ./src/main/resources/application-common.yml
touch ./src/main/resources/application-local.yml
echo "${{secrets.APPLICATION_LOCAL}}" > ./src/main/resources/application-local.yml
touch ./src/main/resources/application-prod.yml
echo "${{secrets.APPLICATION_PROD}}" > ./src/main/resources/application-prod.yml
touch ./src/main/resources/application-test.yml
echo "${{secrets.APPLICATION_TEST}}" > ./src/main/resources/application-test.yml
## Gradle
- name: Cache gradle packages
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: Verify MySQL connection
run: |
sleep 30
mysql --host 127.0.0.1 --port 3306 --user root --password=root -e "SHOW DATABASES;"
## Build
- name: Build with Gradle
run: ./gradlew clean build

- name: Set up JDK 17
uses: actions/setup-java@v4
Expand Down

0 comments on commit 46653b1

Please sign in to comment.