Merge pull request #155 from yellow-hammer/dependabot/npm_and_yarn/ba… #315
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 GitHub Pages | |
| on: | |
| push: | |
| branches: [main] | |
| # Позволяет запускать workflow вручную из вкладки Actions | |
| workflow_dispatch: | |
| # Разрешаем одновременно только один деплой | |
| concurrency: | |
| group: 'pages' | |
| cancel-in-progress: true | |
| jobs: | |
| # Тестируем сборку на разных версиях Node.js перед деплоем | |
| test-build: | |
| name: Тест сборки на Node.js ${{ matrix.node-version }} | |
| permissions: | |
| contents: read | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| node-version: [20, 22] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build website | |
| run: npm run build | |
| - name: Check build output | |
| run: | | |
| if [ ! -d "build" ]; then | |
| echo "❌ Ошибка: директория build не создана" | |
| exit 1 | |
| fi | |
| if [ ! -f "build/index.html" ]; then | |
| echo "❌ Ошибка: файл build/index.html не найден" | |
| exit 1 | |
| fi | |
| echo "✅ Сборка успешна на Node.js ${{ matrix.node-version }}" | |
| - name: Upload build artifact for deploy | |
| if: matrix.node-version == 20 | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: build-node20 | |
| path: ./build | |
| if-no-files-found: error | |
| deploy: | |
| name: Deploy to GitHub Pages | |
| runs-on: ubuntu-latest | |
| needs: test-build | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Download build artifact | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: build-node20 | |
| path: ./build | |
| - name: Upload artifact for GitHub Pages | |
| uses: actions/upload-pages-artifact@v5 | |
| with: | |
| path: ./build | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v5 |