66 lines
2.0 KiB
YAML
66 lines
2.0 KiB
YAML
name: Build & Deploy
|
|
|
|
on:
|
|
pull_request:
|
|
branches: [main]
|
|
types: [opened, synchronize, reopened]
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build-and-deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: "22"
|
|
|
|
# - name: Verify build (locally)
|
|
# run: |
|
|
# npm ci --no-audit --no-fund
|
|
# npm run build
|
|
|
|
- name: Stage source for upload
|
|
run: |
|
|
mkdir .deploy-stage
|
|
tar --exclude=.git --exclude=node_modules --exclude=.next \
|
|
--exclude=.deploy-stage -cf - . | (cd .deploy-stage && tar xf -)
|
|
|
|
- name: Probe FTP server
|
|
run: |
|
|
echo "--- full listing ---"
|
|
curl -s --user "${{ secrets.FTP_USER }}:${{ secrets.FTP_PASS }}" \
|
|
"ftp://82.165.141.176/dev.karlderheinz.tv/"
|
|
echo "--- write test ---"
|
|
echo "probe $(date -u)" > /tmp/probe.txt && \
|
|
curl -s --user "${{ secrets.FTP_USER }}:${{ secrets.FTP_PASS }}" \
|
|
-T /tmp/probe.txt \
|
|
"ftp://82.165.141.176/dev.karlderheinz.tv/deploy-probe-$(date +%s).txt" && echo PUT-OK || echo PUT-FAILED
|
|
|
|
- name: Reproduce MKDIR
|
|
run: |
|
|
apt-get update && apt-get install -y lftp >/dev/null 2>&1 || true
|
|
lftp <<'EOF' 2>&1 | tail -25 || true
|
|
set net:tls:mode disable
|
|
open ftp://${{ secrets.FTP_USER }}:${{ secrets.FTP_PASS }}@82.165.141.176/dev.karlderheinz.tv/
|
|
pwd
|
|
mkdir public
|
|
ls
|
|
bye
|
|
EOF
|
|
|
|
- name: Upload source to server (FTP)
|
|
uses: SamKirkland/FTP-Deploy-Action@4.2.0
|
|
with:
|
|
server: 82.165.141.176
|
|
username: ${{ secrets.FTP_USER }}
|
|
password: ${{ secrets.FTP_PASS }}
|
|
local-dir: .deploy-stage/
|
|
remote-dir: /dev/karlderheinz.tv/
|
|
transfer-method: "passive"
|
|
|
|
# TODO: trigger the server-side build + restart (next conversation)
|