Skip to content

Merge branch 'dev'

Merge branch 'dev' #23

## Based on https://www.andrewvillazon.com/automatically-deploying-with-github-actions/
name: Build and Deploy
on:
push:
branches: main
jobs:
build-and-deploy:
name: Build and deploy Gatsby site
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Set variables
run: |
VER=$(cat .node-version)
echo "NODE_VERSION=$VER" >> $GITHUB_ENV
- name: Install Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install Project Dependencies
run: npm ci
- name: Build
run: npx gatsby build
- name: Verify build
run: ls -la public
- name: Modify .htaccess
run: sed -i -e 's/Options -MultiViews//' public/.htaccess
- name: Setup SSH
run: |
mkdir -p ~/.ssh/
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_key
sudo chmod 600 ~/.ssh/deploy_key
ssh-keyscan -p 10922 -H "${{ secrets.HOST }}" > ~/.ssh/known_hosts
- name: Rsync upload
run: rsync -av -e "ssh -i ~/.ssh/deploy_key -l ${{ secrets.DEPLOY_USER }} -p 10922" public/ ${{ secrets.DEPLOY_USER }}@${{ secrets.HOST }}:html/