Skip to content

Deploy when pushing to main #18

Deploy when pushing to main

Deploy when pushing to main #18

name: Deployment
on:
push:
branches: main
workflow_dispatch:
jobs:
deployment:
runs-on: ubuntu-latest
environment:
name: kindlingx
url: http://kindlingx.com
steps:
- uses: actions/checkout@v3
- name: Set up Node.js 16.x
uses: actions/setup-node@v2
with:
node-version: 16.x
- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.WEBSITE_HOST_KEY }}
- name: Build and Deploy
env:
WEBSITE_HOST: ${{ secrets.WEBSITE_HOST }}
WEBSITE_PATH: ${{ secrets.WEBSITE_PATH }}
run: |
# Set the real domain
sed -i 's|'https://kindlingproject.netlify.app/'|'http://kindlingx.com/'|g' config/production/config.toml
# Build the website
npm install && npm run build
# Compress and transfer the tarball
cd public && tar -cvzf public.tar.gz *
# Add the host key
hostKey='kindlingx.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIfN3rkIrcVwFzs1oRYQ+pmyHmNbRWvikxRl7pRPVL/2'
echo "$hostKey" >> ~/.ssh/known_hosts
scp public.tar.gz "$WEBSITE_HOST":$WEBSITE_PATH/..
# Update the website
ssh "$WEBSITE_HOST" << eof
echo "Removing the old files..."
cd $WEBSITE_PATH && rm -rf *
echo "Deploying the site..."
mv ../public.tar.gz . && tar -xvf public.tar.gz
eof