File: /var/www/staging.fixgini.com/.github/workflows/staging-deploy.yml
name: Staging Deployment
on:
push:
branches:
- staging # Trigger when pushing to the staging branch
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- name: Install dependencies
run: |
composer install
npm install
npm run build
- name: Set up SSH
run: |
mkdir -p ~/.ssh
ssh-keyscan -H ${{ secrets.STAGING_SERVER_IP }} >> ~/.ssh/known_hosts
chmod 700 ~/.ssh
chmod 644 ~/.ssh/known_hosts
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
- name: Deploy to Staging
run: |
ssh -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no root@${{ secrets.STAGING_SERVER_IP }} 'cd /var/www/staging.fixgini.com && git pull origin staging && php artisan migrate'