Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 22 additions & 31 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,19 @@ on:
# Run Mondays and Thursdays at 06:00 UTC to get fresh stats
- cron: "0 6 * * 1,4"

env:
AWS_REGION: eu-west-1
STATS_BUCKET: scverse-stats

jobs:
generate-data:
runs-on: ubuntu-latest
timeout-minutes: 15

permissions:
contents: read
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -37,59 +46,41 @@ jobs:
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
if [ ! -s output/stats.json ]; then
echo "Error: stats.json is empty or does not exist"
exit 1
fi
# Validate JSON syntax
jq empty build/stats.json
jq empty output/stats.json

- name: Upload GitHub Pages artifact
uses: actions/upload-pages-artifact@v3
- name: Configure AWS credentials
if: github.ref == 'refs/heads/main'
uses: aws-actions/configure-aws-credentials@v4
with:
path: "build"
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: ${{ env.AWS_REGION }}

deploy:
- name: Publish stats to S3
if: github.ref == 'refs/heads/main'
run: aws s3 sync output/ "s3://${STATS_BUCKET}/" --exclude "index.html"

trigger-website-build:
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 \
https://api.github.com/repos/scverse/scverse.github.io/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 }}


keepalive-job:
name: Keepalive Workflow
runs-on: ubuntu-slim
Expand Down