rename to evaluators #3
This file contains hidden or 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: Build evaluator index | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - "evaluators/**/evaluator.yaml" | |
| permissions: | |
| contents: write | |
| jobs: | |
| build-index: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install yq | |
| run: | | |
| sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 | |
| sudo chmod +x /usr/local/bin/yq | |
| - name: Build index.yaml from evaluator manifests | |
| run: | | |
| set -euo pipefail | |
| TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ") | |
| cat > index.yaml <<EOF | |
| # AUTO-GENERATED by CI — do not edit manually. | |
| # Source: .github/workflows/build-index.yaml | |
| # Generated: ${TIMESTAMP} | |
| evaluators: | |
| EOF | |
| for manifest in evaluators/*/evaluator.yaml; do | |
| dir=$(dirname "$manifest") | |
| name=$(yq '.name' "$manifest") | |
| description=$(yq '.description' "$manifest") | |
| language=$(yq '.language' "$manifest") | |
| entrypoint=$(yq '.entrypoint' "$manifest") | |
| tags=$(yq -o=json -I=0 '.tags' "$manifest") | |
| author=$(yq '.author' "$manifest") | |
| cat >> index.yaml <<EOF | |
| - name: ${name} | |
| description: "${description}" | |
| language: ${language} | |
| path: ${dir}/${entrypoint} | |
| tags: ${tags} | |
| author: ${author} | |
| EOF | |
| done | |
| # Normalize indentation | |
| sed -i 's/^ //' index.yaml | |
| echo "--- Generated index.yaml ---" | |
| cat index.yaml | |
| - name: Commit and push index.yaml | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add index.yaml | |
| if git diff --cached --quiet; then | |
| echo "No changes to index.yaml" | |
| else | |
| git commit -m "chore: regenerate index.yaml" | |
| git push | |
| fi |