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:35:52 +02:00
runs-on : ubuntu-latest
2024-04-03 16:18:30 +02:00
steps :
- name : Checkout your repository using git
uses : actions/checkout@v4
2024-04-03 16:35:52 +02:00
- name : 📦 Install git-lfs
run : apt update && apt install git-lfs zstd
- name : 📦 Install PNPM
uses : https://github.com/pnpm/action-setup@v2
id : pnpm-install
with :
version : 7
run_install : false
- name : 🔢 Calculate cache ids
run : |
git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
2024-04-03 16:38:44 +02:00
LFS_CACHE_ID=$(cat .lfs-assets-id | md5sum)-v2 # Get the GitHub repository name
PNPM_CACHE_ID=$( cat pnpm-lock.yaml | md5sum )-v2q
2024-04-03 16:35:52 +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 16:18:30 +02:00
- name : 🗳️ Setup pnpm cache
2024-04-03 16:38:44 +02:00
uses : https://github.com/actions/cache@v4
2024-04-03 16:18:30 +02:00
with :
path : ${{ env.PNPM_STORE_PATH }}
key : ${{ runner.os }}-pnpm-store-${{ env.PNPM_CACHE_ID }}
restore-keys : |
${{ runner.os }}-pnpm-store
2024-04-03 16:35:52 +02:00
- name : 📥 Checkout lfs files
run : git lfs pull
- name : 📦 Install pnpm packages
run : pnpm install
- name : Build Website
run : pnpm build
2024-04-03 16:18:30 +02:00
# with:
# path: . # The root location of your Astro project inside the repository. (optional)
# node-version: 20 # The specific version of Node that should be used to build your site. Defaults to 20. (optional)
# package-manager: pnpm@latest # The Node package manager that should be used to install dependencies and build your site. Automatically detected based on your lockfile. (optional)
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'