Skip to content

Build and Deploy

Build and Deploy #22

name: Build and Deploy
on:
workflow_dispatch:
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setting up node.js
uses: actions/setup-node@v4
with:
node-version: '10.15.1'
- name: Installing dependencies
run: npm install
- name: Building the project
run: npm run build_prod
env:
CI: ""
- name: Uploading artifact
uses: actions/upload-artifact@v4
with:
name: build
path: "build/*"
deploy:
name: Deploy
runs-on: ubuntu-latest
environment: production
needs: build
steps:
- name: Pulling build files
uses: actions/download-artifact@v4
with:
name: build
path: ""
- name: Backing up the previous build
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
key: ${{ secrets.KEY }}
username: ${{ secrets.USERNAME }}
script: |
cp -a ${{ secrets.DEPLOY_DIR }} ${{ secrets.DEPLOY_DIR }}.bak-`date +"%s"`
rm -rf ${{ secrets.DEPLOY_DIR }}/*
- name: Sending files to production
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
key: ${{ secrets.KEY }}
username: ${{ secrets.USERNAME }}
source: "*"
target: ${{ secrets.DEPLOY_DIR }}