website/.github/workflows/default.yaml
Max Richter 4b0f214568
Some checks failed
Deploy to SFTP Server / build (push) Failing after 22m0s
fix: ci
2024-04-07 15:38:19 +02:00

78 lines
2.3 KiB
YAML

name: Deploy to SFTP Server
on:
push:
branches: [main]
permissions:
contents: read
pages: write
id-token: write
jobs:
build:
env:
RUNNER_TOOL_CACHE: '/toolcache'
runs-on: ubuntu-latest
container: git.max-richter.dev/max/website:latest
steps:
- name: 🔄 Checkout code
uses: actions/checkout@v3
- name: 🔢 Calculate cache IDs
run: |
# Calculate cache IDs for Git LFS and PNPM
git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
LFS_CACHE_ID=$(cat .lfs-assets-id | md5sum)-v1
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
- name: 🗄️ Cache Git LFS objects
uses: actions/cache@v4
with:
path: .git/lfs
key: ${{ runner.os }}-lfs-${{ env.LFS_CACHE_ID }}
- name: 🛠️ Cache PNPM dependencies
uses: actions/cache@v4
with:
path: ${{ env.PNPM_STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
- name: 📷 Cache Astro Images
uses: actions/cache@v4
with:
path: node_modules/.astro
key: ${{ runner.os }}-astro-v1
- name: print modifify time of the first file under node_modules/.astro without using find
run: |
ls -lt node_modules/.astro/assets | grep "^-" | head -n 1 | awk '{print $6, $7, $8}'
- name: 🔄 Pull Git LFS files
run: git lfs pull
- name: 🏗️ Build site
run: |
# Install dependencies, build, and generate site output
pnpm i && pnpm build
- 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
restoreMTime: false
parallel: '4'
settings: 'sftp:auto-confirm=yes'
localDir: 'dist'
remoteDir: '/share/new-website'
options: '--verbose'