4-build-push-website-to-gh-pages #1233
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: 4-build-push-website-to-gh-pages | |
| # Build and push the website to the gh-pages branch | |
| # Workflow triggered on every push in the "Website" folder or in the "Data/GitHubRepositoriesDetails.json" file in the main branch | |
| # Also validates pull requests that touch the website or generated repository data before merge | |
| # Can also be triggered manually without input parameters | |
| # Also rebuilds after the weekly popularity-score snapshot completes successfully | |
| on: | |
| workflow_run: | |
| workflows: ["3-snapshot-github-repositories-popularity-score"] | |
| types: [completed] | |
| branches: [main] | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'Website/**' | |
| - 'Data/GitHubRepositoriesDetails.json' | |
| - '!.devcontainer/**' | |
| - '!.github/**' | |
| - '!.vscode/**' | |
| - '!Configuration/**' | |
| - '!Data/GitHubRepositoriesPopularityScoresSnapshot.json' | |
| - '!Scripts/**' | |
| - '!.gitignore' | |
| - '!CODE_OF_CONDUCT.md' | |
| - '!LICENSE' | |
| - '!README.md' | |
| pull_request: | |
| branches: | |
| - main | |
| paths: | |
| - 'Website/**' | |
| - 'Data/GitHubRepositoriesDetails.json' | |
| - '!.devcontainer/**' | |
| - '!.github/**' | |
| - '!.vscode/**' | |
| - '!Configuration/**' | |
| - '!Data/GitHubRepositoriesPopularityScoresSnapshot.json' | |
| - '!Scripts/**' | |
| - '!.gitignore' | |
| - '!CODE_OF_CONDUCT.md' | |
| - '!LICENSE' | |
| - '!README.md' | |
| workflow_dispatch: | |
| # Concurrency configuration for the current workflow - Keep only the latest workflow queued for the considered group and the considered issue | |
| concurrency: | |
| group: build-deploy-website-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build-deploy-website: | |
| runs-on: ubuntu-latest | |
| if: github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' | |
| env: | |
| RUNNER_DEBUG: 1 | |
| steps: | |
| # Checkout the repository content | |
| # Action: https://github.com/actions/checkout | |
| - uses: actions/checkout@v7 | |
| # Setup Node.js | |
| # Action: https://github.com/actions/setup-node | |
| - uses: actions/setup-node@v7 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| cache-dependency-path: Website/package-lock.json | |
| # Install dependencies | |
| - name: Install dependencies | |
| working-directory: Website | |
| run: | | |
| npm ci | |
| # Type-check the website code | |
| - name: Type-check website | |
| working-directory: Website | |
| run: | | |
| npm run typecheck | |
| # Build the website | |
| - name: Build website | |
| working-directory: Website | |
| run: | | |
| npm run build | |
| # Run unit tests | |
| - name: Run unit tests | |
| working-directory: Website | |
| run: | | |
| npm run test:unit | |
| # Install Playwright test dependencies | |
| - name: Install Playwright test dependencies | |
| working-directory: Website/tests/user_interface | |
| run: | | |
| npm ci | |
| # Install Playwright Browsers | |
| - name: Install Playwright Browsers | |
| working-directory: Website/tests/user_interface | |
| run: | | |
| npx playwright install --with-deps | |
| # Run user interface tests (Playwright) | |
| - name: Run user interface tests | |
| working-directory: Website/tests/user_interface | |
| run: | | |
| npx playwright test | |
| # Upload Playwright test results to workflow run artifacts | |
| - name: Upload user interface tests report | |
| uses: actions/upload-artifact@v7 | |
| if: always() | |
| with: | |
| name: UserInterfaceTestsReport | |
| path: Website/tests/user_interface/playwright-report | |
| # Push the built website to the workflow artifacts | |
| # Action: https://docs.github.com/en/free-pro-team@latest/actions/guides/storing-workflow-data-as-artifacts | |
| - name: Upload website | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: Website | |
| path: Website/build | |
| # Deploy website to GitHub Pages | |
| # Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus | |
| - name: Deploy to GitHub Pages | |
| if: > | |
| (github.event_name == 'push' && github.ref == 'refs/heads/main') || | |
| (github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main') || | |
| github.event_name == 'workflow_dispatch' | |
| uses: peaceiris/actions-gh-pages@v4 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./Website/build | |
| user_name: 'github-actions[bot]' | |
| user_email: 'github-actions[bot]@users.noreply.github.com' | |
| codeql-analysis: | |
| runs-on: ubuntu-latest | |
| env: | |
| RUNNER_DEBUG: 1 | |
| steps: | |
| # Checkout the repository content | |
| # Action: https://github.com/actions/checkout | |
| - name: Checkout repository | |
| uses: actions/checkout@v7 | |
| # Initializes the CodeQL tools for scanning. | |
| # Action: https://github.com/github/codeql-action | |
| - name: Initialize CodeQL | |
| uses: github/codeql-action/init@v4.37.9 | |
| with: | |
| languages: 'javascript' # Set the language of your project here | |
| # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). | |
| # If this step fails, then you should remove it and run the build manually (see below) | |
| # Action: https://github.com/github/codeql-action | |
| - name: Autobuild | |
| uses: github/codeql-action/autobuild@v4.37.9 | |
| # Perform CodeQL Analysis | |
| # Action: https://github.com/github/codeql-action | |
| - name: Perform CodeQL Analysis | |
| uses: github/codeql-action/analyze@v4.37.9 |