Update Mealie OpenAPI spec #66
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: Update Mealie OpenAPI spec | |
| on: | |
| schedule: | |
| - cron: "17 4 * * *" # daily drift check against the pinned tag | |
| workflow_dispatch: | |
| inputs: | |
| mealie_tag: | |
| description: "Mealie Docker tag to pull the spec from (e.g. v3.21.0, latest, nightly). Blank = the pinned default." | |
| required: false | |
| default: "" | |
| # Auto-track the latest stable Mealie release. Each run pulls that image's real | |
| # version; when the spec changes, the run bumps the version and cuts a release. | |
| # Pin a specific version here (e.g. "v3.20.1") or via the dispatch input to | |
| # freeze on one release instead. | |
| env: | |
| MEALIE_TAG_DEFAULT: "latest" | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| concurrency: | |
| group: update-spec | |
| cancel-in-progress: false | |
| jobs: | |
| update: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 | |
| with: | |
| python-version: "3.14" | |
| - name: Install project (gen_tools needs fastmcp + httpx to measure costs) | |
| run: pip install . | |
| - name: Resolve + validate the Mealie tag | |
| env: | |
| INPUT_TAG: ${{ github.event.inputs.mealie_tag }} | |
| run: | | |
| TAG="${INPUT_TAG:-$MEALIE_TAG_DEFAULT}" | |
| if ! printf '%s' "$TAG" | grep -Eq '^[A-Za-z0-9][A-Za-z0-9._-]*$'; then | |
| echo "::error::Invalid Mealie tag: $TAG"; exit 1 | |
| fi | |
| echo "MEALIE_TAG=$TAG" >> "$GITHUB_ENV" | |
| echo "Using Mealie tag: $TAG" | |
| - name: Boot Mealie ${{ env.MEALIE_TAG }} and capture its version | |
| run: | | |
| docker run -d --name mealie -p 9925:9000 \ | |
| -e ALLOW_SIGNUP=true -e BASE_URL=http://localhost:9925 -e TZ=UTC \ | |
| "ghcr.io/mealie-recipes/mealie:${MEALIE_TAG}" | |
| for i in $(seq 1 80); do | |
| code="$(curl -s -o /dev/null -w '%{http_code}' http://localhost:9925/api/app/about || true)" | |
| [ "$code" = "200" ] && break | |
| sleep 3 | |
| done | |
| VER="$(curl -fsS http://localhost:9925/api/app/about | python -c 'import sys,json;print(json.load(sys.stdin)["version"])')" | |
| echo "MEALIE_VERSION=$VER" >> "$GITHUB_ENV" | |
| echo "Mealie reports version: $VER" | |
| - name: Pull spec, canonicalize, regenerate tool reference | |
| run: | | |
| cp openapi.json /tmp/old-spec.json | |
| curl -fsSL http://localhost:9925/openapi.json -o openapi.json | |
| python scripts/gen_tools.py # normalizes + pretty-writes openapi.json | |
| - name: Open a PR if the spec changed | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| if git diff --quiet; then | |
| echo "Spec unchanged for ${MEALIE_VERSION} — nothing to do." | |
| exit 0 | |
| fi | |
| DATE="$(date -u +%Y-%m-%d)" | |
| TOOLS="$(python -c "import json;from better_mealie_mcp.naming import build_names;print(len(build_names(json.load(open('openapi.json')))))")" | |
| python scripts/set_version.py "$MEALIE_VERSION" "$DATE" "$TOOLS" | |
| # set_version bumps pyproject's version; re-lock so `uv sync --locked` | |
| # (Docker build) keeps working. | |
| pip install uv && uv lock | |
| python scripts/spec_diff.py /tmp/old-spec.json openapi.json > /tmp/notes.md | |
| echo "----- proposed change -----"; cat /tmp/notes.md | |
| # One branch per Mealie version, no date: a stale PR gets force-pushed | |
| # and refreshed instead of piling up a new PR every night. | |
| BRANCH="bot/spec-${MEALIE_VERSION}" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git switch -c "$BRANCH" | |
| git add -A | |
| git commit -m "chore: sync Mealie OpenAPI spec (${MEALIE_VERSION})" | |
| git push -f origin "$BRANCH" | |
| # Open the PR, or refresh its body if one is already open for this branch. | |
| # main is protected — the release is cut on merge by release-on-spec.yml. | |
| gh pr create --base main --head "$BRANCH" \ | |
| --title "chore: sync Mealie OpenAPI spec (${MEALIE_VERSION})" \ | |
| --body-file /tmp/notes.md \ | |
| || gh pr edit "$BRANCH" --body-file /tmp/notes.md | |
| - name: Stop Mealie | |
| if: always() | |
| run: docker rm -f mealie || true |