website/.forgejo/workflows/deploy.yml
2025-02-19 19:51:20 +00:00

58 lines
2 KiB
YAML

name: Build and push to webserver
on: [push]
jobs:
build:
runs-on: docker
container:
image: ${{ vars.BUILDER_CONTAINER_NAME }}
env:
HUGO_CACHEDIR: /tmp/hugo_cache
steps:
# LFS caching courtesy of https://github.com/actions/checkout/issues/165#issuecomment-657673315
- name: Checkout without LFS
uses: actions/checkout@v4
with:
submodules: recursive
lfs: 'false'
- name: Create LFS file list
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
- name: Restore LFS cache
uses: actions/cache@v4
with:
path: .git/lfs
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}-v1
restore-keys: ${{ runner.os }}-lfs-
- name: Git LFS Pull
run: git lfs pull
# Hugo caching
- name: Get current date (for cache eviction)
id: get-date
run: echo "year-month-day=$(date --utc +'%Y%m%d')" >> $GITHUB_OUTPUT
- name: Restore cached build artifacts
uses: actions/cache@v4
with:
# Caches are immutable, create a new cache every day so it's always somewhat fresh.
key: ${{ runner.os }}-hugo-${{ steps.get-date.outputs.year-month-day }}
# If no cache has been created yet today, restore a previous one.
restore-keys: ${{ runner.os }}-hugo-
path: |
resources/_gen/
${{ env.HUGO_CACHEDIR }}
- name: Check
run: just check
- name: Build website
run: just build
- name: Copy to server
if: github.ref == 'refs/heads/master'
run: |
mkdir -p ~/.ssh
chmod -R 700 ~/.ssh
echo "${{ secrets.SSH_WEBSITE }}" > ~/.ssh/id_ed25519
echo "web.srv.it-syndikat.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHBRXGn/UNvz31QMDm1jqR+97aZ0xy6kQS9wnuDOukET" >> ~/.ssh/known_hosts
chmod -R 700 ~/.ssh
rsync -vva --delete-after public/* public/.* deployer@web.srv.it-syndikat.org:/