website/.github/workflows/default.yaml

80 lines
2.2 KiB
YAML
Raw Normal View History

2024-04-03 16:18:30 +02:00
name: Deploy to GitHub Pages
on:
push:
branches: [ main ]
permissions:
contents: read
pages: write
id-token: write
jobs:
build:
2024-04-03 16:48:10 +02:00
env:
RUNNER_TOOL_CACHE: /toolcache
2024-04-03 16:35:52 +02:00
runs-on: ubuntu-latest
2024-04-03 16:18:30 +02:00
steps:
2024-04-03 17:17:10 +02:00
- name: Checkout
uses: actions/checkout@v3
2024-04-03 16:54:19 +02:00
2024-04-03 17:18:45 +02:00
- name: 📦 Install git-lfs
run: apt update && apt install git-lfs zstd
2024-04-03 17:20:56 +02:00
- name: 🔢 Calculate cache ids
run: |
git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
LFS_CACHE_ID=$(cat .lfs-assets-id | md5sum)-v1 # Get the GitHub repository name
PNPM_CACHE_ID=$( cat pnpm-lock.yaml | md5sum )-v1
echo "LFS_CACHE_ID=$LFS_CACHE_ID" >> $GITHUB_ENV
echo "PNPM_STORE_PATH=$(pnpm store path)" >> $GITHUB_ENV
echo "PNPM_CACHE_ID=$PNPM_CACHE_ID" >> $GITHUB_ENV
2024-04-03 17:17:10 +02:00
- name: LFS Cache
uses: actions/cache@v3
with:
path: .git/lfs/objects
2024-04-03 17:20:56 +02:00
key: ${{ runner.os }}-lfs-${{ env.LFS_CACHE_ID }}
2024-04-03 17:17:10 +02:00
restore-keys: |
2024-04-03 16:35:52 +02:00
- name: 📦 Install PNPM
2024-04-03 17:09:47 +02:00
uses: pnpm/action-setup@v3
2024-04-03 16:35:52 +02:00
id: pnpm-install
with:
2024-04-03 16:48:10 +02:00
version: 8
2024-04-03 16:35:52 +02:00
run_install: false
2024-04-03 16:48:10 +02:00
- name: Get pnpm store directory
shell: bash
2024-04-03 16:35:52 +02:00
run: |
2024-04-03 16:48:10 +02:00
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
2024-04-03 16:35:52 +02:00
2024-04-03 16:48:10 +02:00
- uses: actions/cache@v4
name: Setup pnpm cache
2024-04-03 16:18:30 +02:00
with:
2024-04-03 16:48:10 +02:00
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
2024-04-03 16:18:30 +02:00
restore-keys: |
2024-04-03 16:48:10 +02:00
${{ runner.os }}-pnpm-store-
2024-04-03 16:35:52 +02:00
2024-04-03 16:48:10 +02:00
- name: Install, build, and upload your site output
uses: withastro/action@v2
2024-04-03 16:18:30 +02:00
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: 🚀 Deploy files via SFTP
uses: https://github.com/pressidium/lftp-mirror-action@v1
with:
host: ${{ secrets.FTP_HOST }}
port: ${{ secrets.FTP_PORT || 21 }}
user: ${{ secrets.FTP_USERNAME }}
pass: ${{ secrets.FTP_PASSWORD }}
onlyNewer: true
parallel: '4'
settings: 'sftp:auto-confirm=yes'
localDir: 'public'
2024-04-03 16:35:52 +02:00
remoteDir: '/share/new-website'
2024-04-03 16:18:30 +02:00
options: '--verbose'