website/.github/workflows/default.yaml

75 lines
2.1 KiB
YAML
Raw Normal View History

2024-04-06 15:33:22 +02:00
name: Deploy to SFTP Server
2024-04-03 16:18:30 +02:00
on:
push:
2024-04-06 15:33:22 +02:00
branches: [main]
2024-04-03 16:18:30 +02:00
permissions:
contents: read
pages: write
id-token: write
jobs:
build:
2024-04-03 16:48:10 +02:00
env:
2024-04-06 15:33:22 +02:00
RUNNER_TOOL_CACHE: '/toolcache'
2024-04-03 16:35:52 +02:00
runs-on: ubuntu-latest
2024-04-06 16:43:38 +02:00
container: git.max-richter.dev/max/website:latest
2024-04-03 16:18:30 +02:00
steps:
2024-04-06 15:33:22 +02:00
- name: 🔄 Checkout code
2024-04-03 17:17:10 +02:00
uses: actions/checkout@v3
2024-04-03 16:54:19 +02:00
2024-04-06 17:58:22 +02:00
- name: CHeck tar varsion
run: tar --version
2024-04-06 15:33:22 +02:00
- name: 🔢 Calculate cache IDs
2024-04-03 17:20:56 +02:00
run: |
2024-04-06 15:33:22 +02:00
# Calculate cache IDs for Git LFS and PNPM
2024-04-03 17:20:56 +02:00
git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
2024-04-06 15:33:22 +02:00
LFS_CACHE_ID=$(cat .lfs-assets-id | md5sum)-v1
PNPM_CACHE_ID=$(cat pnpm-lock.yaml | md5sum)-v1
2024-04-03 17:20:56 +02:00
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
2024-04-06 15:33:22 +02:00
- name: 🗄️ Cache Git LFS objects
uses: actions/cache@v4
2024-04-03 17:17:10 +02:00
with:
2024-04-06 15:33:22 +02:00
path: .git/lfs
2024-04-03 17:20:56 +02:00
key: ${{ runner.os }}-lfs-${{ env.LFS_CACHE_ID }}
2024-04-03 16:35:52 +02:00
2024-04-06 15:33:22 +02:00
- name: 🛠️ Cache PNPM dependencies
uses: actions/cache@v4
2024-04-03 16:18:30 +02:00
with:
2024-04-06 16:00:15 +02:00
path: ${{ env.PNPM_STORE_PATH }}
2024-04-03 16:48:10 +02:00
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
2024-04-03 16:35:52 +02:00
2024-04-06 16:33:30 +02:00
- name: 📷 Cache Astro Images
uses: actions/cache@v4
with:
path: node_modules/.astro
key: ${{ runner.os }}-astro-v1
2024-04-06 15:33:22 +02:00
- name: 🔄 Pull Git LFS files
2024-04-03 20:07:32 +02:00
run: git lfs pull
2024-04-06 15:33:22 +02:00
- name: 🏗️ Build site
run: |
# Install dependencies, build, and generate site output
pnpm i && pnpm build
2024-04-03 16:18:30 +02:00
2024-04-05 21:12:48 +02:00
- name: 🚀 Deploy files via SFTP
uses: 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: 'dist'
remoteDir: '/share/new-website'
options: '--verbose'
2024-04-06 15:33:22 +02:00