Skip to content

[test] CI/CD 테스트 #219

[test] CI/CD 테스트

[test] CI/CD 테스트 #219

Workflow file for this run

name: Deploy CI/CD 파이프라인
on:
push:
branches:
- dtest
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/myapp:latest
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to Ncloud
uses: appleboy/[email protected]
with:
host: ${{ secrets.NCLOUD_SERVER_IP }}
username: ${{ secrets.NCLOUD_USERNAME }}
password: ${{ secrets.NCLOUD_PASSWORD }}
port: ${{ secrets.NCLOUD_SSH_PORT }}
script: |
echo "Logging in to Docker Hub..."
echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
echo "Pulling latest image..."
docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/myapp:latest
echo "Stopping existing container..."
docker stop myapp || true
echo "Removing existing container..."
docker rm myapp || true
echo "Running new container..."
docker run -d --name myapp -p 3000:3000 -p 8080:8080 --env-file /root/src/config/.env ${{ secrets.DOCKER_HUB_USERNAME }}/myapp:latest