Skip to content

Commit

Permalink
build: deploy workflow 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
dladncks1217 committed Jul 13, 2024
1 parent 70cb95d commit 21c41ed
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 1 deletion.
54 changes: 54 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: frontend deploy
on:
push:
branches:
- feat/36

jobs:
docker_image_push:
name: Push to container registry
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to NCP Container Registry
uses: docker/login-action@v2
with:
registry: ${{ secrets.CONTAINER_REGISTRY_URL }}
username: ${{ secrets.NCP_ACCESS_KEY }}
password: ${{ secrets.NCP_SECRET_KEY }}

- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.CONTAINER_REGISTRY_URL }}/tag-name:latest
cache-from: type=registry,ref=${{ secrets.CONTAINER_REGISTRY_URL }}/prv-frontend:latest
cache-to: type=inline
secrets: |
GIT_AUTH_TOKEN=${{ secrets.GITHUB_TOKEN }}
docker_image_pull:
name: Connect server ssh and pull from container registry
needs: docker_image_push
runs-on: ubuntu-latest
steps:
- name: Connect SSH
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.NCP_SERVER_HOST }}
username: ${{ secrets.NCP_SERVER_USERNAME }}
password: ${{ secrets.NCP_SERVER_PASSWORD }}
port: ${{ secrets.NCP_SERVER_PORT }}
script: |
docker pull ${{ secrets.CONTAINER_REGISTRY_URL }}/tag-name
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker run -d -p 3000:80 --env-file ${{ secrets.ENV_FILENAME_FRONTEND }} ${{ secrets.CONTAINER_REGISTRY_URL }}/tag-name
docker image prune -f
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ node_modules

localhost+1-key.pem
localhost+1.pem
*.pem
*.pem

my.secrets
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM node:20

WORKDIR /app

COPY package*.json ./
RUN npm install

COPY . .

CMD ["npm", "run", "dev"]

0 comments on commit 21c41ed

Please sign in to comment.