Skip to content

Deployment (Production) #98

Deployment (Production)

Deployment (Production) #98

Workflow file for this run

name: Deployment (Production)
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
environment: prod
steps:
- name: Repository checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
- name: Retrive caches
uses: actions/cache@v4
with:
path: node_modules
key: ${{ hashFiles('yarn.lock') }}
- name: Enable corepack
run: corepack enable
- name: Install project
run: yarn install --immutable
- name: Build
run: yarn build
env:
VITE_API_URL: ${{ vars.VITE_API_URL }}
VITE_REDIRECT_URI: ${{ vars.VITE_REDIRECT_URI }}
VITE_REST_API_KEY: ${{ secrets.VITE_REST_API_KEY }}
- name: Compress build artifacts
run: tar -cvf ./dist.tar ./dist
- name: Upload with SCP
uses: appleboy/[email protected]
with:
username: ubuntu
host: ${{ secrets.SSH_HOST }}
key: ${{ secrets.SSH_KEY }}
source: "dist.tar"
target: "/home/ubuntu/"
- name: Extract artifact with SSH
uses: appleboy/[email protected]
with:
username: ubuntu
host: ${{ secrets.SSH_HOST }}
key: ${{ secrets.SSH_KEY }}
script: |
tar -xvf ./dist.tar ./dist
sudo rm -rf /var/www/homepage-frontend
sudo mv ./dist /var/www/homepage-frontend
rm -rf ./dist
rm -f ./dist.tar