Skip to content

Create frontend deploy script #1

Create frontend deploy script

Create frontend deploy script #1

Workflow file for this run

name: Deploy Frontend
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build Frontend
uses: docker/setup-buildx-action@v1
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
run: |
docker build -t devruby/l2s-frontend:latest ./frontend
docker push devruby/l2s-frontend:latest
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to server
uses: appleboy/[email protected]
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
docker pull my-dockerhub-username/l2s-frontend:latest
docker stop l2s-frontend || true
docker rm l2s-frontend || true
docker run -d --name l2s-frontend -p 3001:3000 devruby/l2s-frontend:latest