add workflow and embed
Nightly build & deploy / build-and-deploy (push) Failing after 8m23s

This commit is contained in:
2026-09-19 00:59:55 -04:00
parent 31d5322b38
commit db75d5bfe7
5 changed files with 383 additions and 3 deletions
+88
View File
@@ -0,0 +1,88 @@
name: Nightly build & deploy
# Rebuilds the site (refreshing the Discord embed's "today" snapshot), uploads
# the built dist/ to the CMU AFS space over SFTP, then triggers CMU's publish
# CGI so the files go live.
on:
# Midnight run. NOTE: cron here is UTC. 00:00 UTC is 8pm/7pm Eastern.
# For midnight *Eastern*, use "0 5 * * *" (EST) or "0 4 * * *" (EDT).
schedule:
- cron: "0 5 * * *"
# Allow manual runs from the Gitea Actions UI.
workflow_dispatch: {}
# Also deploy on pushes to the main branch.
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest
env:
# Absolute base URL where the site is served. Used to build the absolute
# icon URL embedded for Discord. Set SITE_BASE_URL as a secret/variable,
# e.g. https://www.andrew.cmu.edu/user/<username>
SITE_BASE_URL: ${{ secrets.SITE_BASE_URL }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Build (injects today's Red-plan embed)
env:
# Discord fetches this absolute URL for the embed thumbnail.
SITE_ICON_URL: "${{ secrets.SITE_BASE_URL }}/apple-touch-icon.png"
run: npm run build
- name: Install lftp
run: |
sudo apt-get update
sudo apt-get install -y lftp
- name: Upload dist/ via SFTP
env:
SFTP_HOST: ${{ secrets.SFTP_HOST }}
SFTP_PORT: ${{ secrets.SFTP_PORT }}
SFTP_USERNAME: ${{ secrets.SFTP_USERNAME }}
SFTP_PASSWORD: ${{ secrets.SFTP_PASSWORD }}
SFTP_REMOTE_PATH: ${{ secrets.SFTP_REMOTE_PATH }}
run: |
set -euo pipefail
PORT="${SFTP_PORT:-22}"
# Mirror the local dist/ into the remote path.
# -R : reverse mirror (local -> remote)
# --delete : remove remote files no longer present locally
# --verbose : log transferred files
# Host key checking is disabled because CMU's key is not pre-seeded on
# the runner; the connection is still encrypted.
lftp -c "
set sftp:auto-confirm yes;
set net:max-retries 3;
set net:timeout 20;
open -u '${SFTP_USERNAME}','${SFTP_PASSWORD}' sftp://${SFTP_HOST}:${PORT};
mirror -R --delete --verbose ./dist/ '${SFTP_REMOTE_PATH}';
bye
"
- name: Trigger CMU publish
env:
SFTP_USERNAME: ${{ secrets.SFTP_USERNAME }}
run: |
set -euo pipefail
# FLAG=0 publishes; NAME is the AFS username (same as the SFTP user).
# --fail makes curl exit non-zero on HTTP errors so the job fails
# loudly if publishing is rejected.
curl --fail --show-error --silent \
"https://www.andrew.cmu.edu/cgi-bin/publish?FLAG=0&NAME=${SFTP_USERNAME}"
echo "Publish request sent for ${SFTP_USERNAME}."