The deployment was only pulling code via git but not rebuilding the Docker images, causing containers to run with stale code from the registry image. This fixes the debug error pages still showing on staging despite APP_DEBUG=false.
74 lines
2.1 KiB
YAML
74 lines
2.1 KiB
YAML
name: Deploy Application
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- staging
|
|
- main
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: php-ci
|
|
steps:
|
|
# Manual checkout - works without Node.js
|
|
- name: Checkout code
|
|
run: |
|
|
echo "📥 Checking out repository..."
|
|
if [ -d ".git" ]; then
|
|
git fetch origin
|
|
git checkout ${{ github.ref_name }}
|
|
git reset --hard origin/${{ github.ref_name }}
|
|
else
|
|
git clone --branch ${{ github.ref_name }} --single-branch ${{ github.server_url }}/${{ github.repository }}.git .
|
|
fi
|
|
|
|
- name: Determine environment
|
|
id: env
|
|
run: |
|
|
if [ "${{ github.ref }}" == "refs/heads/staging" ]; then
|
|
echo "environment=staging" >> $GITHUB_OUTPUT
|
|
elif [ "${{ github.ref }}" == "refs/heads/main" ]; then
|
|
echo "environment=production" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "environment=staging" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Deploy to server
|
|
env:
|
|
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
run: |
|
|
# Validate required secret
|
|
if [ -z "$SSH_PRIVATE_KEY" ]; then
|
|
echo "❌ Missing required secret: SSH_PRIVATE_KEY"
|
|
exit 1
|
|
fi
|
|
|
|
echo "$SSH_PRIVATE_KEY" > /tmp/ssh_key
|
|
chmod 600 /tmp/ssh_key
|
|
|
|
ssh -i /tmp/ssh_key -o StrictHostKeyChecking=no deploy@94.16.110.151 << EOF
|
|
set -e
|
|
cd /home/deploy/michaelschiemer/current
|
|
|
|
# Pull latest code
|
|
git fetch origin ${{ github.ref_name }}
|
|
git reset --hard origin/${{ github.ref_name }}
|
|
|
|
# Run deployment script with image build
|
|
./deployment/scripts/deploy.sh ${{ steps.env.outputs.environment }} build
|
|
EOF
|
|
|
|
rm -f /tmp/ssh_key
|
|
|
|
- name: Deployment status
|
|
if: always()
|
|
run: |
|
|
if [ "${{ job.status }}" == "success" ]; then
|
|
echo "✅ Deployment successful"
|
|
else
|
|
echo "❌ Deployment failed"
|
|
exit 1
|
|
fi
|
|
|