4-build-push-website-to-gh-pages #415
This file contains 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 | |
# Can also be triggered manually without input parameters | |
on: | |
push: | |
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 | |
cancel-in-progress: true | |
jobs: | |
build-deploy-website: | |
runs-on: ubuntu-latest | |
env: | |
RUNNER_DEBUG: 1 | |
steps: | |
# Checkout the repository content | |
# Action: https://github.com/actions/checkout | |
- uses: actions/checkout@v4 | |
# Setup Node.js | |
# Action: https://github.com/actions/setup-node | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: npm | |
cache-dependency-path: Website/package-lock.json | |
# Install dependencies | |
- name: Install dependencies | |
working-directory: Website | |
run: | | |
npm ci | |
# 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 Browsers | |
- name: Install Playwright Browsers | |
working-directory: Website/tests/user_interface | |
run: | | |
npx playwright install --with-deps | |
npm install @playwright/test | |
# Run user interface tests (Playwright) | |
- name: Run user interface tests | |
working-directory: Website/tests/user_interface | |
run: | | |
npm ci | |
npx playwright test | |
# Upload Playwright test results to workflow run artifacts | |
- name: Upload user interface tests report | |
uses: actions/upload-artifact@v4 | |
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@v4 | |
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 | |
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@v4 | |
# Initializes the CodeQL tools for scanning. | |
# Action: https://github.com/github/codeql-action | |
- name: Initialize CodeQL | |
uses: github/codeql-action/init@v3 | |
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@v3 | |
# Perform CodeQL Analysis | |
# Action: https://github.com/github/codeql-action | |
- name: Perform CodeQL Analysis | |
uses: github/codeql-action/analyze@v3 |