On this page
Guides / Run a Met from GitHub Actions

Run a Met from GitHub Actions

Put a Met inside your pipeline — summarize a deploy, review a change, deploy a flow — with the exit code reflecting the result.

Updated View .md
StackGitHub Actions · Meteor CLI
Endpointsmet run · met flows push · met runs list

The CLI covers the same API as the SDK, so anything your backend does a CI step can do too. This recipe runs a Met when something happens in the repository, and makes the pipeline fail if the run failed.

Before you start

Store two secrets in the repository (Settings → Secrets and variables → Actions):

secretwhat it is
MET_API_KEYa met_live_ key with whatever scopes your step uses
MET_WORKSPACEthe numeric workspace id

The CLI reads both environment variables directly, so there's no met config set in CI.

1. A Met that summarizes what just shipped

name: Deploy summary

on:
  push:
    branches: [main]

jobs:
  summarize:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 20

      - run: npm i -g @meteor.ia/cli

      - name: Summarize the pushed commits
        env:
          MET_API_KEY: ${{ secrets.MET_API_KEY }}
          MET_WORKSPACE: ${{ secrets.MET_WORKSPACE }}
        run: |
          COMMITS=$(git log --format='%s' -20)
          met run "Summarize these commits for the support team, in three bullets: $COMMITS" \
            --json --no-stream > output.json
          jq -r '.output' output.json >> "$GITHUB_STEP_SUMMARY"

--json prints the whole run as indented JSON, ready for jq, and it also turns streaming off: the CLI waits for the run to finish and only then prints. With --json, --no-stream is redundant; it stays written because without --json it is what keeps the CLI from painting the answer as it arrives, which in a CI log would end up as fragments.

2. A run that can fail the pipeline

With --json --no-stream, met run waits for the whole run and prints its JSON, with status set to completed or failed. A run that ends in failed doesn't change the exit code by itself, so the step checks it with jq -e:

      - name: Pre-release review
        env:
          MET_API_KEY: ${{ secrets.MET_API_KEY }}
          MET_WORKSPACE: ${{ secrets.MET_WORKSPACE }}
        run: |
          met run "Review this release's CHANGELOG and tell me if anything is missing" \
            --met reviewer --json --no-stream > review.json
          jq -e '.status == "completed"' review.json

jq -e exits with 1 when the condition doesn't hold: the step fails and the pipeline stops. If the call itself fails (invalid key, no Energy), met run already exits with 1 before reaching jq.

met tasks run no longer exists. This step used to run a task with met tasks run tsk_123 --wait. Task execution was retired on August 31, 2026, and the command now answers with an error that explains it. A procedure with steps that runs on its own is built as a flow (step 3), and what needs a person is assigned to them as a task, outside CI.

3. Deploy a flow from the repository

If you keep your flows in git, the pipeline uploads them on every merge. met flows pull exports them to a .flow.json and met flows push imports them back:

      - name: Upload the collections flow
        env:
          MET_API_KEY: ${{ secrets.MET_API_KEY }}
          MET_WORKSPACE: ${{ secrets.MET_WORKSPACE }}
          FLOW_ID: 8f14e45f-ceea-467a-9f0b-4c3d1a2b5e60
        run: met flows push flows/collections.flow.json --target "$FLOW_ID"

With --target it updates that flow instead of creating another one, so running it twice leaves the same flow. It always lands as a draft: importing doesn't publish. Publish it from the panel once you've reviewed it, or with met.flows.publish() from the SDK if that step is automated too. The key needs flows:write to upload it and automations:execute to publish it.

4. A look at what went wrong

Useful as a final step when something failed, or as a scheduled job:

met runs list --status failed --limit 20

Energy is consumed all the same

A run from CI costs the same as one from your backend, and a workflow that fires on every push adds up fast. Two things help: use a separate key for CI, and give it a budget — subscribe to billing.threshold and you get a heads-up at 50, 80 and 100% instead of a surprise. Per-key consumption is in your dashboard under Developers.

Next