Skip to content

indexer

indexer #7349

Workflow file for this run

name: indexer
# we have to generate an index for each pkg so that the index.html that is
# served has the correct metadata
#TODO a lambda would be better because we copy the index.html from the bucket
# root and modify it then push that back so it could easily get out of sync
on:
workflow_call:
workflow_dispatch:
schedule:
- cron: "13 * * * *"
pull_request:
branches: main
paths:
- .github/scripts/indexer.ts
- .github/workflows/indexer.yml
concurrency:
group: indexer/${{ github.ref || 'main' }}
cancel-in-progress: true
jobs:
indexer:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: pkgxdev/pantry
path: pantry
fetch-depth: 0 # needed to get git metadata for ordering purposes
- uses: pkgxdev/setup@v3
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.WWW_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.WWW_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- run: aws s3 sync s3://www.pkgx.dev/pkgs/ ./out
- run: aws s3 cp s3://www.pkgx.dev/index.html ./out/index.html
- run: ../.github/scripts/gen-pkgs-index.json.ts > ../out/index.json
working-directory: pantry
- run: cat ./out/index.html
- run: .github/scripts/gen-index.html.ts
- run: aws s3 sync
out/ s3://www.pkgx.dev/pkgs/
--metadata-directive REPLACE
--cache-control no-cache,must-revalidate
- run: aws cloudfront
create-invalidation
--distribution-id E15VQ3SI584CSG
--paths /pkgs /pkgs/ /pkgs/*
- uses: actions/upload-artifact@v4
with:
path: out/index.json
root-indexer:
needs: indexer
runs-on: ubuntu-latest
steps:
- uses: pkgxdev/setup@v3
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: pkgxdev/pantry
path: pantry
- uses: actions/download-artifact@v4
- run: curl https://pkgxdev.github.io/mash/index.json > scripthub.json
- run: |
.github/scripts/gen-feed.ts \
--blog-path ./blog \
--pkgs-json ./artifact/index.json \
--scripthub-json ./scripthub.json \
--pantry-path ./pantry \
> index.json
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.WWW_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.WWW_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- run: aws s3 cp index.json s3://www.pkgx.dev/index.json
- run: aws cloudfront
create-invalidation
--distribution-id E15VQ3SI584CSG
--paths /index.json
algolia:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: pkgxdev/pantry
fetch-depth: 0 # needed to get git metadata for ordering purposes
- uses: actions/checkout@v4
with:
path: utils
- uses: pkgxdev/setup@v3
- run: utils/.github/scripts/gen-algolia-data.ts > algolia.json
- name: Upload JSON file to Algolia
env:
ALGOLIA_APP_ID: UUTLHX01W7
ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_ADMIN_KEY }}
INDEX_NAME: pkgs
JSON_FILE: ./algolia.json
run: |
curl -X POST \
-H "X-Algolia-Application-Id: $ALGOLIA_APP_ID" \
-H "X-Algolia-API-Key: $ALGOLIA_API_KEY" \
-H "Content-Type: application/json" \
--data-binary "@$JSON_FILE" \
"https://${ALGOLIA_APP_ID}-dsn.algolia.net/1/indexes/$INDEX_NAME/batch"