Some checks failed
site-dist-deploy / build-and-deploy (push) Failing after 2m13s
109 lines
3.1 KiB
YAML
109 lines
3.1 KiB
YAML
name: site-dist-deploy
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- develop
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
- develop
|
|
|
|
|
|
env:
|
|
VITE_APP_BASE_URL: https://h.hifast.biz
|
|
SSH_HOST: ${{ vars.PRO_SSH_HOST }}
|
|
SSH_PORT: ${{ vars.PRO_SSH_PORT }}
|
|
SSH_USER: ${{ vars.PRO_SSH_USER }}
|
|
SSH_PASSWORD: ${{ vars.PRO_SSH_PASSWORD }}
|
|
DEPLOY_PATH: /var/www/down
|
|
|
|
jobs:
|
|
build-and-deploy:
|
|
runs-on: landing-hero-web01
|
|
steps:
|
|
- name: Manual checkout (no Node required)
|
|
run: |
|
|
set -e
|
|
if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
|
git fetch --all --tags
|
|
git checkout "${{ github.ref_name }}"
|
|
git reset --hard "origin/${{ github.ref_name }}"
|
|
else
|
|
REPO_URL="${{ github.server_url }}/${{ github.repository }}"
|
|
echo "Cloning $REPO_URL"
|
|
git clone --depth=1 --branch "${{ github.ref_name }}" "$REPO_URL" .
|
|
git fetch --tags
|
|
fi
|
|
|
|
- name: Build dist with Unified Script
|
|
env:
|
|
VITE_APP_BASE_URL: "https://h.hifast.biz"
|
|
run: |
|
|
chmod +x scripts/ci-build.sh
|
|
./scripts/ci-build.sh
|
|
|
|
- name: Prepare target directory
|
|
uses: appleboy/ssh-action@v1.0.3
|
|
with:
|
|
host: ${{ env.SSH_HOST }}
|
|
username: ${{ env.SSH_USER }}
|
|
password: ${{ env.SSH_PASSWORD }}
|
|
port: ${{ env.SSH_PORT }}
|
|
timeout: 300s
|
|
script: |
|
|
mkdir -p ${{ env.DEPLOY_PATH }}
|
|
rm -rf ${{ env.DEPLOY_PATH }}/*
|
|
mkdir -p /tmp/ci-upload
|
|
|
|
- name: Check Artifacts
|
|
run: |
|
|
echo "Current directory: $(pwd)"
|
|
echo "Listing all files in workspace:"
|
|
find . -maxdepth 2 -not -path '*/.*'
|
|
if [ -f "site_dist.tgz" ]; then
|
|
echo "✅ File exists: site_dist.tgz"
|
|
ls -lh site_dist.tgz
|
|
echo "File path: $(readlink -f site_dist.tgz)"
|
|
else
|
|
echo "❌ File NOT found: site_dist.tgz"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Upload dist archive
|
|
uses: appleboy/scp-action@v0.1.7
|
|
with:
|
|
host: ${{ env.SSH_HOST }}
|
|
username: ${{ env.SSH_USER }}
|
|
password: ${{ env.SSH_PASSWORD }}
|
|
port: ${{ env.SSH_PORT }}
|
|
source: "site_dist.tgz"
|
|
target: "/tmp/ci-upload"
|
|
overwrite: true
|
|
debug: true
|
|
|
|
- name: Extract archive to deploy path
|
|
uses: appleboy/ssh-action@v1.0.3
|
|
with:
|
|
host: ${{ env.SSH_HOST }}
|
|
username: ${{ env.SSH_USER }}
|
|
password: ${{ env.SSH_PASSWORD }}
|
|
port: ${{ env.SSH_PORT }}
|
|
timeout: 300s
|
|
script: |
|
|
cd ${{ env.DEPLOY_PATH }}
|
|
tar -xzf /tmp/ci-upload/site_dist.tgz
|
|
rm -f /tmp/ci-upload/site_dist.tgz
|
|
|
|
- name: Reload Nginx
|
|
uses: appleboy/ssh-action@v1.0.3
|
|
with:
|
|
host: ${{ env.SSH_HOST }}
|
|
username: ${{ env.SSH_USER }}
|
|
password: ${{ env.SSH_PASSWORD }}
|
|
port: ${{ env.SSH_PORT }}
|
|
timeout: 300s
|
|
script: |
|
|
nginx -t && nginx -s reload
|