All checks were successful
Deploy / Deploy (push) Successful in 17s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
83 lines
2.9 KiB
YAML
83 lines
2.9 KiB
YAML
name: Deploy
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- preprod
|
|
|
|
jobs:
|
|
deploy:
|
|
name: Deploy
|
|
runs-on: docker
|
|
container:
|
|
image: forgejo-ci-php:latest
|
|
steps:
|
|
- name: Checkout code
|
|
run: |
|
|
git clone --depth 50 --branch ${{ github.ref_name }} https://oauth2:${{ github.token }}@forge.studio-variable.com/${{ github.repository }}.git .
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
composer install --no-dev --optimize-autoloader
|
|
|
|
- name: Set deploy host
|
|
id: host
|
|
shell: bash
|
|
run: |
|
|
if [ "${{ github.ref_name }}" = "preprod" ]; then
|
|
echo "ftp_host=${{ secrets.PREPRODUCTION_HOST }}" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "ftp_host=${{ secrets.PRODUCTION_HOST }}" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Deploy via FTP
|
|
env:
|
|
USERNAME: ${{ secrets.USERNAME }}
|
|
PASSWORD: ${{ secrets.PASSWORD }}
|
|
FTP_HOST: ${{ steps.host.outputs.ftp_host }}
|
|
shell: bash
|
|
run: |
|
|
BEFORE="${{ github.event.before }}"
|
|
ZEROS="0000000000000000000000000000000000000000"
|
|
|
|
if [ "$BEFORE" != "$ZEROS" ] && git cat-file -e "${BEFORE}^{commit}" 2>/dev/null; then
|
|
INCREMENTAL=true
|
|
echo "=== Mode incrémental — fichiers modifiés depuis $BEFORE ==="
|
|
git diff --name-status "$BEFORE" HEAD
|
|
echo "============================================================"
|
|
else
|
|
INCREMENTAL=false
|
|
echo "=== Mode full mirror (premier push ou BEFORE hors portée) ==="
|
|
fi
|
|
|
|
{
|
|
echo "set ftp:ssl-allow no"
|
|
echo "set cmd:fail-exit no"
|
|
echo "open -u $USERNAME,$PASSWORD $FTP_HOST"
|
|
|
|
if $INCREMENTAL; then
|
|
git diff --name-status "$BEFORE" HEAD | while IFS=$'\t' read -r status file; do
|
|
case "$file" in local/*|site/accounts/*|site/cache/*|site/sessions/*) continue ;; esac
|
|
if [ "$status" = "D" ]; then
|
|
echo "rm -f \"$file\""
|
|
elif [ -f "$file" ]; then
|
|
echo "mkdir -p \"$(dirname "$file")\""
|
|
echo "put \"$file\" -o \"$file\""
|
|
fi
|
|
done
|
|
else
|
|
echo "mirror --reverse --verbose --ignore-time --parallel=10 -x local/ assets assets"
|
|
echo "mirror --reverse --verbose --ignore-time --parallel=10 -x accounts/ -x cache/ -x sessions/ site site"
|
|
fi
|
|
|
|
echo "mirror --reverse --verbose --ignore-time --parallel=10 kirby kirby"
|
|
echo "mirror --reverse --verbose --ignore-time --parallel=10 vendor vendor"
|
|
echo "quit"
|
|
} > /tmp/lftp-script.txt
|
|
|
|
echo "=== Script lftp généré ==="
|
|
cat /tmp/lftp-script.txt
|
|
echo "=========================="
|
|
|
|
lftp -f /tmp/lftp-script.txt
|