Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI/CD] 최신 코드를 빌드하지 못 하는 이슈 해결 #43

Merged
merged 13 commits into from
Nov 14, 2024
38 changes: 10 additions & 28 deletions .github/workflows/dev-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ on:
push:
branches: [ "develop" ]

env:
DOCKERHUB_IMAGE_NAME: gigedi-server

jobs:

build-deploy:
runs-on: ubuntu-latest
environment: DEV

steps:
- name: Checkout code
uses: actions/checkout@v3
Expand Down Expand Up @@ -45,34 +44,17 @@ jobs:

- name: Extract Docker metadata
id: metadata
uses: docker/metadata-action@v5.5.0
uses: docker/metadata-action@v4
with:
images: ${{ secrets.DOCKER_USERNAME }}/${{ env.DOCKERHUB_IMAGE_NAME }}
images: ${{ secrets.DOCKER_USERNAME }}/shoot
tags: |
type=sha,prefix=

type=ref,event=branch
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.metadata.outputs.tags }}
run: |
docker build . -t ${{ secrets.DOCKER_USERNAME }}/shoot:latest
docker push ${{ secrets.DOCKER_USERNAME }}/shoot:latest

# - name: Create .env file from GitHub Secrets
# run: |
# echo "${{ secrets.ENV_FILE }}" > .env
#
# - name: Copy .env and docker-compose.yml to EC2
# uses: appleboy/scp-action@master
# with:
# host: ${{ secrets.AWS_EC2_IP }}
# username: ${{ secrets.AWS_EC2_USER }}
# key: ${{ secrets.AWS_EC2_SSH_KEY }}
# source: |
# .env
# docker-compose.yml
# target: "/home/ubuntu/"
# port: 22

- name: Deploy on EC2
uses: appleboy/ssh-action@master
Expand All @@ -83,6 +65,6 @@ jobs:
port: 22
script: |
cd /home/ubuntu
sudo docker pull cowboysj/shoot:latest
docker pull ${{ secrets.DOCKER_USERNAME }}/shoot:latest
docker-compose down
docker-compose up -d
docker-compose up -d
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=linux/amd64 openjdk:17-jdk-alpine
FROM openjdk:17-jdk-alpine
WORKDIR /app
COPY build/libs/*.jar app.jar
ENTRYPOINT ["java", "-jar", "app.jar"]
Expand Down
Loading