chore: cicd test (compose 시작) #21
Workflow file for this run
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
name: CI and CD in WashPedia Project | |
on: | |
push: | |
branches: [ "feature/develop-deploy-in-vultr" ] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Set docker-compose yml file | |
- uses: actions/checkout@v3 | |
- run: | | |
touch docker-compose.yml | |
echo "${{ secrets.DOCKER_COMPOSE }}" > docker-compose.yml | |
- name: Replace SQL Queries | |
run: | | |
sql_dir_path="./module-api/src/main/resources/db/migration" | |
sql_old_text="changeRequired" | |
sql_new_text="${{ secrets.PUBLIC_KEY }}" | |
find "$sql_dir_path" -type f -name "*.sql" -exec sed -i "s|$sql_old_text|$sql_new_text|g" {} + | |
- name: Replace Java Config | |
run: | | |
java_file_path="./module-common/src/main/java/com/kernel360/utils/jasypt/EncryptionConfiguration.java" | |
java_old_text="이 곳에 secret-key를 넣으세요" | |
java_new_text="${{ secrets.PUBLIC_KEY }}" | |
sed -i "s/$java_old_text/$java_new_text/g" $java_file_path | |
- name: Set application yml file | |
uses: microsoft/variable-substitution@v1 | |
with: | |
files: ./module-api/src/main/resources/application.yml | |
env: | |
spring.profiles.active: "dev" | |
- name: Set application-dev yml file | |
uses: microsoft/variable-substitution@v1 | |
with: | |
files: ./module-api/src/main/resources/application-dev.yml | |
env: | |
spring.datasource.url: ${{ secrets.DB_URL }} | |
spring.datasource.username: ${{ secrets.DB_USER }} | |
spring.datasource.password: ${{ secrets.DB_PW }} | |
- name: Grant execute permission for gradlew | |
working-directory: ./module-api | |
run: chmod +x ./gradlew | |
- name: Build with Gradle | |
working-directory: ./module-api | |
run: ./gradlew clean build | |
- name: DockerHub Login | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Docker Image Build | |
working-directory: ./module-api | |
run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.MODULE_API_NAME }} . --platform=linux/amd64 | |
- name: DockerHub Push | |
working-directory: ./module-api | |
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.MODULE_API_NAME }} | |
- name: Application Run | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.VULTR_IP }} | |
username: ${{ secrets.VULTR_USERNAME }} | |
password: ${{ secrets.VULTR_PW }} | |
script: | | |
echo pwd | |
docker-compose pull | |
docker-compose down | |
docker-compose up -d |