Demo: stale materialized spec #4
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: Grapity materialize check | |
| # Variant for public specs served by a registry that allows anonymous reads | |
| # (auth mode "none"), such as the grapity-registry spec on | |
| # registry.grapity.dev. No registry credentials required. | |
| on: | |
| pull_request: | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| materialize-check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install grapity CLI | |
| run: curl -fsSL https://packages.grapity.dev/install.sh | sh | |
| - name: Configure registry remote | |
| run: | | |
| { | |
| echo "mode: remote" | |
| echo "remote:" | |
| echo " url: ${{ vars.GRAPITY_REGISTRY_URL }}" | |
| echo " auth:" | |
| echo " mode: none" | |
| } > "$RUNNER_TEMP/grapity-config.yaml" | |
| - name: Check materialized specs | |
| id: check | |
| env: | |
| GRAPITY_CONFIG_PATH: ${{ runner.temp }}/grapity-config.yaml | |
| run: | | |
| EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) | |
| { | |
| echo "result<<$EOF" | |
| grapity materialize --check --json | |
| echo "$EOF" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Build PR comment | |
| id: comment | |
| env: | |
| RESULT: ${{ steps.check.outputs.result }} | |
| run: | | |
| if [ "$(echo "$RESULT" | jq -r '.stale')" = "true" ]; then | |
| { | |
| echo "> [!WARNING]" | |
| echo "> **Spec drift detected**: materialized specs are behind the registry." | |
| echo "" | |
| echo "| Spec | Materialized | Latest |" | |
| echo "| --- | --- | --- |" | |
| echo "$RESULT" | jq -r '.specs[] | select(.stale) | "| \(.name) | \(.resolved) | \(.latest) |"' | |
| echo "" | |
| echo "Run \`grapity materialize --force\` locally and commit the updated specs to resolve." | |
| } > comment.md | |
| else | |
| { | |
| echo "> [!TIP]" | |
| echo "> **Specs up to date**: all materialized specs match the latest registry versions." | |
| } > comment.md | |
| fi | |
| - name: Upsert sticky PR comment | |
| if: always() | |
| uses: marocchino/sticky-pull-request-comment@v3 | |
| with: | |
| header: materialize-check | |
| skip_unchanged: true | |
| path: comment.md |