Health Check #706
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: Health Check | |
on: | |
push: | |
branches: ['main'] | |
workflow_dispatch: | |
schedule: | |
- cron: '0 */2 * * *' | |
issues: | |
types: [opened, closed] | |
env: | |
ARTIFACT_NAME: reports | |
jobs: | |
get-metrics: | |
runs-on: ubuntu-latest | |
name: Health check endpoints | |
defaults: | |
run: | |
working-directory: ./log | |
permissions: | |
contents: read | |
actions: read | |
packages: write | |
issues: read | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
- name: Get npm cache directory | |
id: npm-cache-dir | |
shell: bash | |
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT} | |
- name: Use cached node_modules | |
uses: actions/cache@v4 | |
id: npm-cache | |
with: | |
path: ${{ steps.npm-cache-dir.outputs.dir }} | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Install dependencies | |
run: npm ci | |
- run: npm run build | |
- name: Health Check | |
run: npm start | |
id: metrics | |
env: | |
SOURCES: | | |
GitHub->https://github.com | |
Facebook->https://facebook.com | |
GITHUB_TOKEN: ${{ github.token }} | |
JOB_NAME: ${{ github.workflow }} | |
ARTIFACT_NAME: ${{ env.ARTIFACT_NAME }} | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.ARTIFACT_NAME }} | |
path: ${{ steps.metrics.outputs.file }} | |
if-no-files-found: error | |
retention-days: 5 | |
overwrite: true | |
build-site: | |
runs-on: ubuntu-latest | |
name: Build Site | |
needs: [get-metrics] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
- name: Get npm cache directory | |
id: npm-cache-dir | |
shell: bash | |
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT} | |
- name: Use cached node_modules | |
uses: actions/cache@v4 | |
id: npm-cache | |
with: | |
path: ${{ steps.npm-cache-dir.outputs.dir }} | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- uses: actions/download-artifact@v4 | |
with: | |
name: ${{ env.ARTIFACT_NAME }} | |
path: logs | |
- name: Replace reports | |
run: cat $FILE > ./src/lib/logs.json | |
env: | |
FILE: logs/${{ env.ARTIFACT_NAME }}.json | |
- name: Install dependencies | |
run: npm ci | |
- run: npm run build | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: build | |
path: ./build | |
if-no-files-found: error | |
retention-days: 3 | |
deploy-to-github-pages: | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
permissions: | |
pages: write | |
id-token: write | |
runs-on: ubuntu-latest | |
name: Deploy Site to GitHub Pages | |
needs: [build-site] | |
steps: | |
- name: Download page | |
uses: actions/download-artifact@v4 | |
with: | |
name: build | |
path: ./dist | |
- name: Setup Pages | |
uses: actions/configure-pages@v4 | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: ./dist | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |