testing new deploy #14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy to ThePlayground | |
| on: | |
| push: | |
| branches: [ "master" ] | |
| workflow_dispatch: # Manual deploy trigger | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v4 | |
| - name: Set up PHP 8.3 | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: "8.3" | |
| extensions: mbstring, intl, json, pdo, pdo_mysql | |
| - name: Install Composer dependencies | |
| run: composer install --no-interaction --no-dev --optimize-autoloader | |
| - name: PHP lint | |
| run: find ./ -type f -name "*.php" -print0 | xargs -0 -n1 php -l | |
| - name: Run tests | |
| if: ${{ hashFiles('phpunit.xml', 'phpunit.xml.dist') != '' }} | |
| run: vendor/bin/phpunit --colors=never | |
| - name: Prepare build folder | |
| run: | | |
| mkdir -p build | |
| rsync -av --exclude=".git" --exclude=".github" --exclude="build" ./ build/ | |
| # ------------------------- | |
| # DRY-RUN DEPLOY | |
| # ------------------------- | |
| - name: Dry-run deploy via rsync | |
| id: dryrun | |
| run: | | |
| echo "Starting dry-run..." | |
| mkdir -p ~/.ssh | |
| echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_key | |
| chmod 600 ~/.ssh/deploy_key | |
| rsync -avz --delete --dry-run \ | |
| --exclude=".well-known" \ | |
| --exclude="cgi-bin" \ | |
| --exclude=".ftpquota" \ | |
| --exclude=".htaccess" \ | |
| -e "ssh -p ${{ secrets.SSH_PORT }} -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no" \ | |
| build/ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/home/cerberus/public_html/theplayground | |
| # Optional: display dry-run output in PR (if PR) | |
| - name: Comment on PR with dry-run output | |
| if: github.event_name == 'pull_request' | |
| uses: marocchino/sticky-pull-request-comment@v2 | |
| with: | |
| header: deploy-preview | |
| message: | | |
| **Dry-run deployment summary** | |
| ``` | |
| ${{ steps.dryrun.outputs.stdout }} | |
| ``` | |
| # ------------------------- | |
| # REAL DEPLOY (manual approval recommended) | |
| # ------------------------- | |
| - name: Deploy via rsync | |
| if: github.event_name == 'workflow_dispatch' | |
| run: | | |
| echo "Starting real deploy..." | |
| mkdir -p ~/.ssh | |
| echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_key | |
| chmod 600 ~/.ssh/deploy_key | |
| rsync -avz --delete \ | |
| --exclude=".well-known" \ | |
| --exclude="cgi-bin" \ | |
| --exclude=".ftpquota" \ | |
| --exclude=".htaccess" \ | |
| -e "ssh -p ${{ secrets.SSH_PORT }} -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no" \ | |
| build/ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/home/cerberus/public_html/theplayground |