🚀 FTP Deploy #20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a workflow for github - ftp host synchronization | |
name: 🚀 FTP Deploy | |
on: | |
workflow_run: | |
workflows: ["Checks", "CodeQL"] | |
types: | |
- completed | |
jobs: | |
deploy: | |
name: 🎉 Deploy to FTP | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- name: 🚚 Get latest code | |
uses: actions/checkout@v2 | |
- name: Install pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: 9 | |
- name: ℹ️ Current repo dir | |
run: | | |
echo "Testing the checkout action..." | |
ls -a | |
- name: 🚧 Build project | |
run: | | |
echo "Building the project..." | |
pnpm install | |
pnpm build | |
mkdir -p build | |
echo "Exporting to /build ..." | |
cp -r .next public build/ | |
env: | |
WORDPRESS_GRAPHQL_ENDPOINT: ${{ secrets.WORDPRESS_GRAPHQL_ENDPOINT }} | |
#- name: 💾 Backup files on FTP | |
# run: | | |
# # Install lftp if not available | |
# sudo apt-get update | |
# sudo apt-get install -y lftp | |
# Define FTP server details | |
# FTP_SERVER=${{ secrets.FTP_SERVER }} | |
# FTP_USER=${{ secrets.FTP_USER }} | |
# FTP_PASSWORD=${{ secrets.FTP_PASSWORD }} | |
# FTP_DIR=${{ secrets.FTP_DIR }} | |
# FTP_BAK_DIR=${{ secrets.FTP_BAK_DIR }} | |
# Clear backup directory | |
# lftp -u "$FTP_USER","$FTP_PASSWORD" ftps://$FTP_SERVER << EOF | |
# set ftp:ssl-allow yes | |
# cd $FTP_BAK_DIR | |
# rm -rf * | |
# quit | |
# EOF | |
# Copy files from FTP_DIR to FTP_BAK_DIR | |
# lftp -u "$FTP_USER","$FTP_PASSWORD" ftps://$FTP_SERVER << EOF | |
# set ftp:ssl-allow yes | |
# mirror --reverse --verbose --no-perms --no-symlinks --parallel=2 $FTP_DIR $FTP_BAK_DIR | |
# quit | |
# EOF | |
# timeout-minutes: 30 | |
- name: 📂 Sync files | |
uses: SamKirkland/FTP-Deploy-Action@v4.3.5 | |
with: | |
server: ${{ secrets.FTP_SERVER }} | |
server-dir: ${{ secrets.FTP_DIR }} | |
dangerous-clean-slate: true | |
username: ${{ secrets.FTP_USER }} | |
password: ${{ secrets.FTP_PASSWORD }} | |
local-dir: ./build/ | |
protocol: ftps |