Skip to content

fix: prod.yml 파일 루트 변경 #27

fix: prod.yml 파일 루트 변경

fix: prod.yml 파일 루트 변경 #27

name: ItcastBuildAndTest
on:
push:
branches:
- main
- issue/**
pull_request:
branches:
- main
- issue/**
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Install Docker Compose
run: |
sudo apt-get update
sudo apt-get install -y docker-compose
- name: Set up Docker Compose
run: |
docker-compose up -d
docker-compose ps
- name: Wait for services to be ready
run: |
until docker-compose exec -T mysql mysqladmin ping -h"127.0.0.1" --silent; do
echo "Waiting for MySQL to be ready"
sleep 5
done
sleep 10
- name: Build with Gradle
run: |
chmod +x ./gradlew
./gradlew clean build -x test -Duser.language=ko -Duser.country=KR
- name: Tear down Docker Compose
if: always()
run: docker-compose down
# DI
- name: Ensure application-prod.yml exists
run: touch ./application-prod.yml
- name: Set Yaml
uses: microsoft/variable-substitution@v1
with:
files: ./application-prod.yml
env:
spring.datasource.url: ${{secrets.KJH_MYSQL_URL}}
spring.datasource.username: ${{ secrets.KJH_DB_USERNAME }}
spring.datasource.password: ${{ secrets.KJH_DB_PASSWORD }}
spring.data.redis.host: ${{ secrets.KJH_REDIS_HOST }}
spring.data.redis.port: ${{ secrets.KJH_REDIS_PORT }}
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
shell: bash
- name: Make Zip file
run: zip -r $GITHUB_SHA.zip build/libs/*.jar appspec.yml scripts/deploy.sh
shell: bash
- name: AWS credential setting
uses: aws-actions/configure-aws-credentials@v3
with:
aws-region: ${{secrets.AWS_KJH_REGION}}
aws-access-key-id: ${{secrets.AWS_KJH_ACCESS_KEY}}
aws-secret-access-key: ${{secrets.AWS_KJH_SECRET_ACCESS_KEY}}
- name: Upload to S3
run: aws s3 cp ./$GITHUB_SHA.zip s3://${{ secrets.AWS_S3_BUCKET }}/$GITHUB_SHA.zip
- name: EC2 Deploy
run: aws deploy create-deployment
--application-name ${{secrets.AWS_KJH_CODE_DEPLOY_APPLICATION}}
--deployment-config-name CodeDeployDefault.AllAtOnce
--deployment-group-name ${{secrets.AWS_KJH_CODE_DEPLOY_GROUP}}
--s3-location bucket=${{secrets.AWS_KJH_S3_BUCKET}},key=$GITHUB_SHA.zip,bundleType=zip