Skip to content

Commit

Permalink
fix: build-and-deploy가 보이지 않는 문제 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamiwood committed Dec 20, 2024
1 parent 2dc171e commit af6d8c1
Showing 1 changed file with 74 additions and 2 deletions.
76 changes: 74 additions & 2 deletions .github/workflows/itcast-build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,80 @@ on:

jobs:
deploy:
if: >
github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Deploy
run: echo "Triggered"
- name: Checkout code
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Set Yaml
uses: microsoft/variable-substitution@v1
with:
files: ./src/main/resources/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: 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 (prod profile)
run: ./gradlew clean build -Dspring.profiles.active=prod -Duser.language=ko -Duser.country=KR

- name: Tear down Docker Compose
if: always()
run: docker-compose down

- 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

0 comments on commit af6d8c1

Please sign in to comment.