Skip to content

update

update #2

name: Deploy homepage
on:
push:
branches:
- main
paths:
- 'homepage-1.3/**'
- '.github/workflows/deploy-homepage.yml'
workflow_dispatch:
permissions:
contents: read
concurrency:
group: homepage-production
cancel-in-progress: true
jobs:
deploy:
runs-on: ubuntu-latest
env:
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
DEPLOY_PORT: ${{ secrets.DEPLOY_PORT || '22' }}
DEPLOY_PATH: ${{ secrets.DEPLOY_PATH || '/www/wwwroot/homepage/homepage-1.3' }}
steps:
- name: Check out repository with Git LFS
uses: actions/checkout@v4
with:
lfs: true
- name: Configure SSH
shell: bash
env:
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
DEPLOY_KNOWN_HOSTS: ${{ secrets.DEPLOY_KNOWN_HOSTS }}
run: |
set -euo pipefail
test -n "$DEPLOY_HOST"
test -n "$DEPLOY_USER"
test -n "$DEPLOY_SSH_KEY"
test -n "$DEPLOY_KNOWN_HOSTS"
install -m 700 -d "$HOME/.ssh"
printf '%s\n' "$DEPLOY_SSH_KEY" > "$HOME/.ssh/id_ed25519"
printf '%s\n' "$DEPLOY_KNOWN_HOSTS" > "$HOME/.ssh/known_hosts"
chmod 600 "$HOME/.ssh/id_ed25519" "$HOME/.ssh/known_hosts"
- name: Sync homepage to production
shell: bash
run: |
set -euo pipefail
rsync -az --delete --no-owner --no-group \
-e "ssh -p $DEPLOY_PORT -i $HOME/.ssh/id_ed25519 -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes" \
homepage-1.3/ "$DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH/"