Skip to content

!hotfix : cors Url ์ˆ˜์ • #53

!hotfix : cors Url ์ˆ˜์ •

!hotfix : cors Url ์ˆ˜์ • #53

Workflow file for this run

name: FitPet_A CI/CD
on:
push:
branches:
- develop
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: develop
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y openjdk-17-jdk
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew clean build -x test
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build Docker Image
run: |
# Build Docker image
echo "Building Docker image..."
docker build --no-cache -t ${{ secrets.DOCKER_USERNAME }}/fitpet-a:latest .
- name: Push Docker Image
run: |
IMAGE_NAME=${{ secrets.DOCKER_USERNAME }}/fitpet-a:latest
# Push Docker image to Docker Hub
echo "Pushing Docker image to Docker Hub..."
docker push ${{ secrets.DOCKER_USERNAME }}/fitpet-a:latest
- name: Deploy EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ubuntu
key: ${{ secrets.KEY }}
script: |
echo "Stopping and removing existing Docker container fitpet-container (if exists)..."
sudo docker stop fitpet-container || true
sudo docker rm fitpet-container || true
echo "Starting new Docker container fitpet-container..."
sudo docker run -d -p 8080:8080 --name fitpet-container \
-e DB_USERNAME=${{ secrets.DB_USERNAME }} \
-e DB_PASSWORD=${{ secrets.DB_PASSWORD }} \
-e ACCESS_TOKEN_EXP=${{ secrets.ACCESS_TOKEN_EXP }} \
-e REFRESH_TOKEN_EXP=${{ secrets.REFRESH_TOKEN_EXP }} \
${{ secrets.DOCKER_USERNAME }}/fitpet-a:latest
echo "Pruning unused Docker objects to free up space..."
sudo docker system prune -a --volumes -f