Skip to content

~23.01.01 작업사항 (#141) #16

~23.01.01 작업사항 (#141)

~23.01.01 작업사항 (#141) #16

Workflow file for this run

name: 'Build and deploy'
on:
push:
branches: ['main']
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and Push to DockerHub
uses: docker/build-push-action@v3
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
- name: Deploy
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.SSH_PORT }}
script: |
docker pull ${{ steps.meta.outputs.tags }}
docker stop $(docker ps -a -q -f "NAME=${{ secrets.DOCKER_NAME }}")
docker rm $(docker ps -a -q -f "NAME=${{ secrets.DOCKER_NAME }}")
docker run -d -p 3000:3000 --name ${{ secrets.DOCKER_NAME }} ${{ steps.meta.outputs.tags }}
docker image prune -f