Skip to content

Merge: 2์ฐจ์™„์„ฑ๋ฐฐํฌ #18

Merge: 2์ฐจ์™„์„ฑ๋ฐฐํฌ

Merge: 2์ฐจ์™„์„ฑ๋ฐฐํฌ #18

Workflow file for this run

name: Build and Deploy
on:
pull_request:
branches:
- main
types:
- closed
jobs:
build-and-deploy:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set image name with date
run: echo "IMAGE_NAME=ticle-client:$(date +'%Y%m%d%H%M')" >> $GITHUB_ENV
- name: Check Dockerfile
run: |
ls -la
cat Dockerfile
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}
- name: SSH Remote Commands
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
command_timeout: 200m
username: ${{ secrets.USER }}
key: ${{ secrets.SSH_KEY }}
script: |
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}
docker rm -f ticle-client || true
docker images -q | xargs -r docker rmi
docker run -d -p 3001:80 --name ticle-client ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}