Skip to content

🚀 deploy config update #4

🚀 deploy config update

🚀 deploy config update #4

Workflow file for this run

name: Build and Push Docker Image with Jib
on:
push:
branches: ["main"]
permissions:
contents: read
jobs:
build-and-push-image:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3 # 서브모듈 관련 옵션 제거
- name: Copy application-prod.yml
run: |
mkdir -p src/main/resources
cp path/to/application-prod.yml src/main/resources/application-prod.yml
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: "21"
distribution: "temurin"
- name: Build and push Docker image
run: |
./gradlew jib -x test \
-Djib.to.tags=${{ github.sha }} \
-Djib.to.auth.username=${{ secrets.DOCKER_USERNAME }} \
-Djib.to.auth.password=${{ secrets.DOCKER_PASSWORD }}
- name: Push Docker image to EC2 server
env:
DOCKER_IMAGE: "${{ secrets.DOCKER_USERNAME }}/learnMate:${{ github.sha }}"
run: |
ssh -o "StrictHostKeyChecking=no" -i ${{ secrets.EC2_SSH_KEY }} ec2-user@${{ secrets.EC2_HOST }} "docker pull $DOCKER_IMAGE && docker run -d -p 8080:8080 $DOCKER_IMAGE"