Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Generate and deploy scverse stats #87

Generate and deploy scverse stats

Generate and deploy scverse stats #87

Workflow file for this run

name: Generate and deploy scverse stats
on:
push:
branches: [main]
workflow_dispatch:
schedule:
# Run daily at 06:00 UTC to get fresh stats
- cron: "0 6 * * *"
jobs:
generate-data:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Generate scverse stats
env:
GITHUB_TOKEN: ${{ secrets.BOT_GH_TOKEN }}
ZULIP_EMAIL: ${{ secrets.ZULIP_EMAIL }}
ZULIP_API_KEY: ${{ secrets.ZULIP_API_KEY }}
ZULIP_REALM: ${{ secrets.ZULIP_REALM }}
PEPY_API_KEY: ${{ secrets.PEPY_API_KEY }}
run: |
npm start
- name: Prepare build directory
run: |
mkdir -p build
touch build/.nojekyll
cp -r output/* build/
- name: Check if stats.json exists and is valid
run: |
if [ ! -s build/stats.json ]; then
echo "Error: stats.json is empty or does not exist"
exit 1
fi
# Validate JSON syntax
jq empty build/stats.json
- name: Upload GitHub Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: "build"
deploy:
runs-on: ubuntu-latest
needs: generate-data
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
if: github.ref == 'refs/heads/main'
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
- name: Trigger website build
run: |
curl -XPOST \
-u "scverse-bot:${{ secrets.BOT_GH_TOKEN }}" \
-H "Accept: application/vnd.github.everest-preview+json" \
-H "Content-Type: application/json" \
https://api.github.com/repos/scverse/stats/actions/workflows/gh-pages.yml/dispatches \
--data '{"ref": "main"}'
# - name: Configure AWS credentials
# uses: aws-actions/configure-aws-credentials@v4
# with:
# role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
# aws-region: ${{ env.AWS_REGION }}