Skip to content

Deploy to GitHub Pages #328

Deploy to GitHub Pages

Deploy to GitHub Pages #328

Workflow file for this run

name: Deploy to GitHub Pages
on:
push:
branches:
- main
workflow_dispatch:
workflow_run:
workflows: ["Fetch Traffic Data", "Fetch Stars Data"]
types:
- completed
branches:
- main
schedule:
- cron: '5 0 * * *'
permissions:
contents: write
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
if: github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: main
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Install dependencies
run: npm install
- name: Merge archive traffic data
run: npm run merge-traffic-data
- name: Merge archive stars data
run: npm run merge-stars-data
- name: Commit merged data (if changed)
if: github.event_name == 'schedule' || github.event_name == 'workflow_run'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add src/data/merged-gh-traffic-data.ts src/data/merged-gh-stars-data.ts
if ! git diff --staged --quiet; then
git commit -m "chore: update merged data [skip ci]"
git push
fi
- name: Build
run: npm run build
- name: Add .nojekyll
run: touch ./dist/.nojekyll
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./dist
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4