45 lines
1.7 KiB
YAML
45 lines
1.7 KiB
YAML
name: Deploy Portfolio to Production
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Setup SSH Key
|
|
run: |
|
|
mkdir -p ~/.ssh
|
|
echo "${{ secrets.DEPLOY_PRIVATE_KEY }}" > ~/.ssh/id_rsa
|
|
chmod 600 ~/.ssh/id_rsa
|
|
printf "Host %s\n IdentityFile ~/.ssh/id_rsa\n StrictHostKeyChecking accept-new\n" "${{ secrets.DEPLOY_HOST }}" >> ~/.ssh/config
|
|
chmod 600 ~/.ssh/config
|
|
- name: Deploy via SSH (git pull + publish)
|
|
run: |
|
|
ssh -o ConnectTimeout=15 ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }} << 'DEPLOY_SCRIPT'
|
|
set -e
|
|
REPO_URL="http://onie:125icko@@100.101.65.69:3033/onie/portfolio.git"
|
|
WORKDIR="/home/gosa/portfolio"
|
|
TARGET="/DATA/AppData/portfolio/index.html"
|
|
echo "=== Portfolio Deployment Started ==="
|
|
if [ ! -d "$WORKDIR/.git" ]; then
|
|
echo "Cloning repo first time..."
|
|
rm -rf "$WORKDIR"
|
|
git clone -b main "$REPO_URL" "$WORKDIR"
|
|
fi
|
|
cd "$WORKDIR"
|
|
git fetch origin
|
|
git checkout main
|
|
git reset --hard origin/main
|
|
echo "Copying index.html to nginx volume..."
|
|
cp index.html /tmp/pf-index.html
|
|
echo "125icko@" | su -c "cp /tmp/pf-index.html $TARGET && echo DEPLOYED-OK"
|
|
echo "=== Deployment Completed ==="
|
|
DEPLOY_SCRIPT
|
|
- name: Verify Deployment
|
|
run: |
|
|
sleep 5
|
|
curl -s -o /dev/null -w "gosambi.uk=%{http_code}\n" https://gosambi.uk/ --max-time 15
|
|
curl -s -o /dev/null -w "www.gosambi.uk=%{http_code}\n" https://www.gosambi.uk/ --max-time 15
|