Skip to content

Update README.md

Update README.md #20

Workflow file for this run

name: Java CI and Deploy to AWS EC2 (Mock Docker Deployment)
on:
push:
branches: [ "readme" ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Save SSH key
env:
EC2_SSH_KEY: ${{ secrets.EC2_SSH_KEY }}
run: |
echo "$EC2_SSH_KEY" > ec2-key.pem
chmod 600 ec2-key.pem
- name: Upload source code to EC2
env:
EC2_HOST: ${{ secrets.EC2_HOST }}
EC2_USER: ${{ secrets.EC2_USER }}
run: |
scp -i ec2-key.pem -o StrictHostKeyChecking=no -r ./* $EC2_USER@$EC2_HOST:/home/$EC2_USER/app
- name: Mock Build and Deploy on EC2
env:
EC2_HOST: ${{ secrets.EC2_HOST }}
EC2_USER: ${{ secrets.EC2_USER }}
run: |
ssh -i ec2-key.pem -o StrictHostKeyChecking=no $EC2_USER@$EC2_HOST << 'EOF'
MOCK=true
# λΉŒλ“œ 단계
if [ "$MOCK" = true ]; then
echo "EC2μ—μ„œ μ• ν”Œλ¦¬μΌ€μ΄μ…˜ λΉŒλ“œ 쀑..."
echo "./gradlew clean build -x test"
else
./gradlew clean build -x test
fi
# Docker 이미지 λΉŒλ“œ 단계
if [ "$MOCK" = true ]; then
echo "Docker 이미지λ₯Ό λΉŒλ“œν•˜λŠ” 쀑..."
echo "docker build -t care-app:latest ."
else
docker build -t care-app:latest .
fi
# κΈ°μ‘΄ μ»¨ν…Œμ΄λ„ˆ 쀑지 및 μ‚­μ œ
if [ "$MOCK" = true ]; then
echo "κΈ°μ‘΄ Docker μ»¨ν…Œμ΄λ„ˆ 쀑지 및 μ‚­μ œ 쀑..."
echo "docker stop care-app-container || true"
echo "docker rm care-app-container || true"
else
docker stop care-app-container || true
docker rm care-app-container || true
fi
# μƒˆ Docker μ»¨ν…Œμ΄λ„ˆ μ‹€ν–‰
if [ "$MOCK" = true ]; then
echo "μƒˆλ‘œμš΄ Docker μ»¨ν…Œμ΄λ„ˆ μ‹€ν–‰ 쀑..."
echo "docker run -d --name care-app-container -v /home/$EC2_USER/app/config/application-secret.yml:/app/config/application-secret.yml -p 8080:8080 care-app:latest"
else
docker run -d --name care-app-container -v /home/$EC2_USER/app/config/application-secret.yml:/app/config/application-secret.yml -p 8080:8080 care-app:latest
fi
echo "배포 μ™„λ£Œ"
EOF