Skip to content

🚀 deploy config update #3

🚀 deploy config update

🚀 deploy config update #3

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 and Submodules
uses: actions/checkout@v3
with:
submodules: true
token: ${{ secrets.GITHUB_TOKEN }}
- name: Copy application.yml from submodule
run: |
mkdir -p src/main/resources
cp application-config/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"