Repository navigation
Merge pull request #32 from NyonCode/0.0.6 #263
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: | |
| push: | |
| branches: | |
| - build | |
| jobs: | |
| web-deploy: | |
| name: 🎉 Build & Deploy | |
| runs-on: ubuntu-latest | |
| environment: deploy | |
| steps: | |
| # 1️⃣ Načti kód | |
| - name: 🚚 Checkout repository | |
| uses: actions/checkout@v4 | |
| # 2️⃣ Připrav .env (pro build i migraci) | |
| - name: 🧩 Prepare .env | |
| run: | | |
| if [ ! -f .env ]; then | |
| cp .env.example .env | |
| fi | |
| # Development/staging režim pro build a migraci | |
| sed -i 's/^APP_ENV=.*/APP_ENV=development/' .env | |
| sed -i 's/^APP_DEBUG=.*/APP_DEBUG=true/' .env | |
| # DB nastavení | |
| sed -i "s/^#\? *DB_CONNECTION=.*/DB_CONNECTION=${{ vars.DB_CONNECTION }}/" .env | |
| sed -i "s/^#\? *DB_HOST=.*/DB_HOST=${{ secrets.DB_HOST }}/" .env | |
| sed -i "s/^#\? *DB_PORT=.*/DB_PORT=${{ secrets.DB_PORT }}/" .env | |
| sed -i "s/^#\? *DB_DATABASE=.*/DB_DATABASE=${{ secrets.DB_DATABASE }}/" .env | |
| sed -i "s/^#\? *DB_USERNAME=.*/DB_USERNAME=${{ secrets.DB_USERNAME }}/" .env | |
| sed -i "s/^#\? *DB_PASSWORD=.*/DB_PASSWORD=${{ secrets.DB_PASSWORD }}/" .env | |
| # 3️⃣ Nainstaluj PHP a Composer | |
| - name: 🧰 Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.4' | |
| extensions: mbstring, bcmath, intl | |
| tools: composer | |
| - name: 📦 Install Composer dependencies | |
| run: composer install --no-dev --optimize-autoloader | |
| # 4️⃣ Build frontend | |
| - name: 🧰 Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: 🔨 Build Project | |
| run: | | |
| echo "📦 Installing Node.js dependencies..." | |
| npm install | |
| echo "🏗️ Building frontend..." | |
| npm run build | |
| # 5️⃣ Upload přes FTP | |
| - name: 📂 Deploy via FTP | |
| uses: SamKirkland/FTP-Deploy-Action@v4.3.5 | |
| with: | |
| server: ${{ secrets.FTP_SERVER }} | |
| username: ${{ secrets.FTP_USER }} | |
| password: ${{ secrets.FTP_PASSWORD }} | |
| server-dir: ${{ vars.FTP_SERVER_DIR }} | |
| exclude: | | |
| **/.git* | |
| **/node_modules/** | |
| **/vendor/** | |
| # 6️⃣ Na serveru: composer install + migrace | |
| - name: ⚙️ Run Composer & Migrate on Server | |
| uses: appleboy/ssh-action@v1.1.0 | |
| with: | |
| host: ${{ secrets.SSH_SERVER }} | |
| username: ${{ secrets.SSH_USER }} | |
| password: ${{ secrets.SSH_PASSWORD }} | |
| port: 22 | |
| script: | | |
| cd storage/d943a45e/92498fdb-2d7a-4965-a7a3-8a5db1f57c3f/patronmonitoring.cz/www | |
| php8.2 /bin/composer install --no-dev --optimize-autoloader | |
| php8.2 artisan migrate --force | |
| # 7️⃣ Přepni na produkční režim | |
| - name: 🧩 Switch to Production | |
| uses: appleboy/ssh-action@v1.1.0 | |
| with: | |
| host: ${{ secrets.SSH_SERVER }} | |
| username: ${{ secrets.SSH_USER }} | |
| password: ${{ secrets.SSH_PASSWORD }} | |
| port: 22 | |
| script: | | |
| cd storage/d943a45e/92498fdb-2d7a-4965-a7a3-8a5db1f57c3f/patronmonitoring.cz/www | |
| sed -i "s/^APP_NAME=.*/APP_NAME='${{ vars.APP_NAME }}'/" .env | |
| sed -i "s/^APP_ENV=.*/APP_ENV=${{ vars.APP_ENV }}/" .env | |
| sed -i "s/^APP_DEBUG=.*/APP_DEBUG=${{ vars.APP_DEBUG }}/" .env | |
| sed -i "s|^APP_URL=.*|APP_URL='${{ vars.APP_URL }}'|" .env | |
| php8.2 artisan optimize:clear | |
| php8.2 artisan storage:link | |
| php8.2 artisan optimize | |
| echo '✅ Environment switched to PRODUCTION mode' |