Skip to content

Commit

Permalink
🌐 [Ci] action script 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
seungheon123 committed Nov 9, 2024
1 parent f3d0aa8 commit 392a332
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/api-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: API Server Ci/Cd
on:
push:
branches:
- Ci/69
- develop
paths:
# - 'apps/api/**'
jobs:
build-and-push:
runs-on: ubuntu-latest

env:
IMAGE_NAME: api-camon

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Log in to Ncloud Container Registry
env:
USERNAME: ${{ secrets.NCLOUD_ACCESS_KEY }}
PASSWORD: ${{ secrets.NCLOUD_SECRET_KEY }}
REGISTRY_URL: ${{ secrets.NCLOUD_REGISTRY_URL }}
run: |
echo "$PASSWORD" | docker login -u "$USERNAME" "$REGISTRY_URL" --password-stdin
- name: Build Docker image
run: |
docker build -t ${{ secrets.NCLOUD_REGISTRY_URL }}/$IMAGE_NAME:latest ./apps/api
- name: Push to Ncloud Container Registry
run: |
docker push ${{ secrets.NCLOUD_REGISTRY_URL }}/$IMAGE_NAME:latest
deploy-and-run:
runs-on: ubuntu-latest
needs: build-and-push
steps:
- name: SSH and deploy
uses: appleboy/[email protected]
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SSH_SERVER_KEY }}
port: 22
script: |
mkdir -p api
cd api
docker pull ${{ secrets.NCLOUD_REGISTRY_URL }}/api-camon:latest
docker stop api-camon || true
docker rm api-camon || true
docker run -d --name api-camon -p 3000:3000 ${{ secrets.NCLOUD_REGISTRY_URL }}/api-camon:latest
- name: Check container status
uses: appleboy/[email protected]
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SSH_SERVER_KEY }}
port: 22
script: |
sudo docker ps -f name=api-camon

0 comments on commit 392a332

Please sign in to comment.