Skip to content

chore(deps): bump cross-spawn from 7.0.3 to 7.0.6 (#77) #71

chore(deps): bump cross-spawn from 7.0.3 to 7.0.6 (#77)

chore(deps): bump cross-spawn from 7.0.3 to 7.0.6 (#77) #71

Workflow file for this run

name: CD
# Controls when the workflow will run
on:
# Triggers the workflow on push events but only for the main branch
push:
branches: [main]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
deploy:
name: Build and Deploy Application to Server
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Check out Git repository
uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: latest
run_install: false
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Run linters
run: pnpm biome ci .
# Add Firebase API keys to environment variables
- name: Add environment variables
uses: SpicyPizza/create-envfile@v1
with:
envkey_REACT_APP_FIREBASE_API_KEY: ${{ secrets.FIREBASE_API_KEY }}
envkey_REACT_APP_FIREBASE_AUTH_DOMAIN: ${{ secrets.FIREBASE_AUTH_DOMAIN }}
envkey_REACT_APP_FIREBASE_DATABASE_URL: ${{ secrets.FIREBASE_DATABASE_URL }}
envkey_REACT_APP_FIREBASE_PROJECT_ID: ${{ secrets.FIREBASE_PROJECT_ID }}
envkey_REACT_APP_FIREBASE_STORAGE_BUCKET: ${{ secrets.FIREBASE_STORAGE_BUCKET }}
envkey_REACT_APP_FIREBASE_MESSAGING_SENDER_ID: ${{ secrets.FIREBASE_MESSAGING_SENDER_ID }}
envkey_REACT_APP_FIREBASE_APP_ID: ${{ secrets.FIREBASE_APP_ID }}
envkey_REACT_APP_FIREBASE_MEASUREMENT_ID: ${{ secrets.FIREBASE_MEASUREMENT_ID }}
- name: Build project
run: pnpm build
- name: Package build
run: |
tar -czvf deploy.tar.gz -C build .
ls
- name: Send packaged build to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
password: ${{ secrets.SSH_PASSWORD }}
port: ${{ secrets.SSH_PORT }}
source: "deploy.tar.gz"
target: ${{ secrets.SERVER_ABSOLUTE_PATH }}
- name: Replace previous version and deploy new one
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
password: ${{ secrets.SSH_PASSWORD }}
port: ${{ secrets.SSH_PORT }}
script_stop: true
script: |
echo "Changing directory to server location"
cd ${{ secrets.SERVER_ABSOLUTE_PATH }}
echo "Moving old version to a temporary folder"
mkdir ../old_version
shopt -s dotglob
mv * ../old_version/
echo "Unzip new version to server location"
tar -xf ../old_version/deploy.tar.gz -C .
echo "Move back db folder to server"
mv ../old_version/db .
echo "Removing old version"
rm -rf ../old_version
shopt -u dotglob
echo "Deployment Complete"