Deploy #70
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 | |
| on: | |
| workflow_run: | |
| workflows: ["CI"] | |
| types: | |
| - completed | |
| branches: | |
| - main | |
| jobs: | |
| deploy: | |
| if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.5' | |
| extensions: pdo, mysql | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '24' | |
| - name: Install Composer dependencies | |
| run: composer install --no-dev --optimize-autoloader | |
| - name: Install Node.js dependencies and build assets | |
| run: | | |
| npm install --omit=dev | |
| npm run build | |
| - name: Prepare deployment directory | |
| run: | | |
| DEPLOY_DIR="../deploy_package" | |
| rm -rf "$DEPLOY_DIR" | |
| mkdir -p "$DEPLOY_DIR" | |
| cp -r public/* "$DEPLOY_DIR" | |
| cp -r vendor "$DEPLOY_DIR" | |
| cp -r bootstrap "$DEPLOY_DIR" | |
| find . -maxdepth 1 \ | |
| \( -path "./$DEPLOY_DIR" -prune \) -o \ | |
| \( -not -path './.*' -a -not -path './public' -a -not -path './vendor' -a -not -path './bootstrap' -a -not -path './node_modules' -a -not -path './storage' -a -not -path './tests' -a -not -path './.git' -a -not -path './.idea' -a -not -path './.vscode' -a -print -exec cp -r {} "$DEPLOY_DIR" \; \) | |
| - name: Elevate directory structure in index.php | |
| run: | | |
| DEPLOY_DIR="../deploy_package" | |
| sed -i "s@__DIR__.'\/\.\.\/@__DIR__.'\/@g" "$DEPLOY_DIR/index.php" | |
| - name: Deploy over FTP | |
| uses: SamKirkland/[email protected] | |
| with: | |
| server: ${{ secrets.FTP_SERVER_ADRESS }} | |
| username: ${{ secrets.FTP_USERNAME }} | |
| password: ${{ secrets.FTP_PASSWORD }} | |
| server-dir: ${{ secrets.FTP_SERVER_DIR }} | |
| local-dir: ../deploy_package/ |