From 2acbca446da3a6ccb2f976fca49b39cd93ba227a Mon Sep 17 00:00:00 2001 From: Alex Chan Date: Sun, 2 Feb 2025 11:27:02 +0000 Subject: [PATCH] Add a "Deploy to Linode" build step --- .github/workflows/build_site.yml | 31 +++++++++++++++++++------------ dev_requirements.txt | 23 +---------------------- netlify.toml | 9 --------- requirements.txt | 12 ------------ scripts/upload_site.sh | 22 ++++++++++++++++++++++ 5 files changed, 42 insertions(+), 55 deletions(-) delete mode 100644 netlify.toml create mode 100755 scripts/upload_site.sh diff --git a/.github/workflows/build_site.yml b/.github/workflows/build_site.yml index 031e383..b0d8a86 100644 --- a/.github/workflows/build_site.yml +++ b/.github/workflows/build_site.yml @@ -69,17 +69,24 @@ jobs: - name: "Render the data as HTML" run: python3 render_data_as_html.py - - name: "Install the Netlify CLI" - run: npm install -g netlify-cli - - - name: "Deploy to Netlify (preview)" - if: github.ref != 'refs/heads/main' - run: netlify deploy --dir=_html/ - env: - NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} - - - name: "Deploy to Netlify (live)" + - name: Deploy to Linode if: github.ref == 'refs/heads/main' - run: netlify deploy --dir=_html/ --prod env: - NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }} + run: | + # Get the SSH host keys for my web server + mkdir -p ~/.ssh + ssh-keyscan -H "alexwlchan.net" >> ~/.ssh/known_hosts + + # Save the deploy key to a file, so it can be used by + # the SSH process + echo "$DEPLOY_KEY" > id_rsa + chmod 600 id_rsa + + # Run the rsync command to upload the _site folder to + # my web server + bash scripts/upload_site.sh \ + --rsh="ssh -i id_rsa -o IdentityAgent=none -o HostKeyAlgorithms=ssh-ed25519" + + # Clean up the SSH key + rm id_rsa diff --git a/dev_requirements.txt b/dev_requirements.txt index 72dbe3d..adcff16 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -15,20 +15,12 @@ certifi==2023.11.17 # -r requirements.txt # httpcore # httpx -cffi==1.17.1 - # via - # -r requirements.txt - # cryptography click==8.1.7 # via interrogate colorama==0.4.6 # via interrogate -coverage[toml]==7.6.4 +coverage==7.6.4 # via pytest-cov -cryptography==43.0.1 - # via - # -r requirements.txt - # secretstorage h11==0.14.0 # via # -r requirements.txt @@ -67,11 +59,6 @@ jaraco-functools==4.0.1 # via # -r requirements.txt # keyring -jeepney==0.8.0 - # via - # -r requirements.txt - # keyring - # secretstorage jinja2==3.1.5 # via -r requirements.txt keyring==25.6.0 @@ -99,10 +86,6 @@ pluggy==1.5.0 # via pytest py==1.11.0 # via interrogate -pycparser==2.22 - # via - # -r requirements.txt - # cffi pytest==8.3.4 # via # -r dev_requirements.in @@ -111,10 +94,6 @@ pytest-cov==6.0.0 # via -r dev_requirements.in ruff==0.9.4 # via -r dev_requirements.in -secretstorage==3.3.3 - # via - # -r requirements.txt - # keyring six==1.16.0 # via # -r requirements.txt diff --git a/netlify.toml b/netlify.toml deleted file mode 100644 index a9c0029..0000000 --- a/netlify.toml +++ /dev/null @@ -1,9 +0,0 @@ -[build] - base = "" - publish = "_html/" - -[[headers]] - for = "/covers/*" - - [headers.values] - cache-control = "public, max-age=31536000" diff --git a/requirements.txt b/requirements.txt index e193264..e30bcd8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,10 +10,6 @@ certifi==2023.11.17 # via # httpcore # httpx -cffi==1.17.1 - # via cryptography -cryptography==43.0.1 - # via secretstorage h11==0.14.0 # via httpcore html5lib==1.1 @@ -35,10 +31,6 @@ jaraco-context==5.3.0 # via keyring jaraco-functools==4.0.1 # via keyring -jeepney==0.8.0 - # via - # keyring - # secretstorage jinja2==3.1.5 # via -r requirements.in keyring==25.6.0 @@ -53,10 +45,6 @@ more-itertools==10.1.0 # jaraco-functools pillow==11.1.0 # via -r requirements.in -pycparser==2.22 - # via cffi -secretstorage==3.3.3 - # via keyring six==1.16.0 # via html5lib sniffio==1.3.0 diff --git a/scripts/upload_site.sh b/scripts/upload_site.sh new file mode 100755 index 0000000..ae5eaf3 --- /dev/null +++ b/scripts/upload_site.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# This script will upload the contents of the local _html folder +# to my web server. +# +# Any arguments passed to this script will be passed to the underlying +# rsync command. + +set -o errexit +set -o nounset +set -o xtrace + +rsync \ + --compress \ + --archive \ + --recursive \ + --delete \ + --verbose \ + --include="" \ + --filter="" \ + "_html/" \ + "alexwlchan@alexwlchan.net:repos/library-lookup/_html/" \ + "$@"