# asc: automation

> asc commands for multi-step workflows, App Store Connect webhooks, Xcode Cloud, Slack notifications and fastlane metadata migration.

Source: https://air.build/docs/cli/asc-automation/

These [asc](https://air.build/docs/cli/asc/) families chain commands together and connect App Store Connect to other tools. They run on cloud Teams and Mac Teams. Picking an Apple team (`--auth`), output, pagination, `--confirm` and exit codes work as described on the [asc](https://air.build/docs/cli/asc/) page.

`workflow`, `notify` and `migrate` are described in full on this page. `webhooks` and `xcode-cloud` have pages of their own; the overview tables here list their **Main flags**. All tables leave out the flags almost every command has: `--output` and `--pretty` (see [Output](https://air.build/docs/cli/asc/#output)), `--limit`, `--next` and `--paginate` on list commands (see [Pagination](https://air.build/docs/cli/asc/#pagination)), and the `--…-fields` flags that pick which attributes Apple returns. Where a subcommand has subcommands of its own, they are listed instead of its flags.

## workflow

Run multi-step automation workflows defined in a workflow file. Every `workflow` command prints JSON on stdout.

| Subcommand | What it does |
| --- | --- |
| [workflow run](https://air.build/docs/cli/asc-automation/#workflow-run) | Run a named workflow. |
| [workflow validate](https://air.build/docs/cli/asc-automation/#workflow-validate) | Validate workflow.json for errors and cycles. |
| [workflow list](https://air.build/docs/cli/asc-automation/#workflow-list) | List available workflows. |

### workflow.json

`asc workflow` reads named workflows from `.asc/workflow.json` (or the file given with `--file`). The file accepts `//` and `/* */` comments. Each step runs an `asc` or shell command, through `bash` with `pipefail` when available, otherwise `sh`.

```json
{
  "env": { "APP_ID": "1234567890" },
  "workflows": {
    "beta": {
      "description": "Send the latest build to a TestFlight group",
      "env": { "GROUP_ID": "" },
      "steps": [
        {
          "name": "resolve_build",
          "run": "asc builds info --app $APP_ID --latest --platform IOS --output json",
          "outputs": { "BUILD_ID": "$.data.id" }
        },
        {
          "name": "add_build_to_group",
          "run": "asc builds add-groups --build-id ${steps.resolve_build.BUILD_ID} --group $GROUP_ID",
          "retry": { "max_attempts": 6, "delay": "10s" },
          "timeout": "2m"
        }
      ]
    }
  }
}
```

- **Params.** `asc workflow run beta GROUP_ID:abcdef` sets `KEY:VALUE` params for that run.
- **Outputs.** A step with `outputs` must print JSON on stdout (pass `--output json` to asc commands). Later steps read them as `${steps.STEP_NAME.KEY}`. Outputs are saved in the run state, so never map secrets into them.
- **Conditions.** `"if": "NAME"` runs a step only when the variable `NAME` is `1`, `true`, `yes`, `y` or `on`; otherwise the step is reported as `skipped`.
- **Hooks.** `before_all`, `after_all` and `error` run a command at those points. A step can also call another workflow with `"workflow": "NAME"` and `"with"` params.
- **Private workflows.** `"private": true` hides a helper workflow from `workflow list`; other workflows can still call it.
- **Retry and timeout** are opt-in per step. `retry.max_attempts` counts the first attempt, `retry.delay` is a fixed wait, and `timeout` applies to each attempt. Use retry only for commands that are safe to repeat. Steps that call a workflow, and hooks, take neither.
- **Output.** stdout is JSON only, even on failure, with a top-level error message and hook results. Step and hook output goes to stderr.
- **Resume.** A run prints a run ID and keeps its state in a `runs` directory next to the workflow file. `asc workflow run NAME --resume RUN_ID` continues without repeating successful steps. Use the same workflow name and no `KEY:VALUE` params. A run cannot be resumed when a step without retry timed out, or when a command succeeded but printed invalid outputs, because the command may already have changed something.

> [!WARNING]
> Workflows run any shell command in the file, with the Environment's variables. Review a workflow file before you run it, especially one passed with `--file`. `asc workflow validate` checks structure and cycles, not whether the commands are safe.

To build and upload in a workflow, build and export the signed IPA with [runbuild](https://air.build/docs/cli/runbuild/), then run `asc publish testflight` (see [asc: review and release](https://air.build/docs/cli/asc-release/)).

### workflow run

Runs the named workflow, given as the first argument, followed by any `KEY:VALUE` params. Prints a JSON result with `workflow`, `status`, `run_id`, `run_file`, the `outputs` of each step and a `steps` list with each step's command, status and duration. Exits `2` when no workflow name is given.

| Flag | What it does | Default |
| --- | --- | --- |
| `--dry-run` | Preview steps without executing. Each command is printed on stderr and reported with status `dry-run`; nothing runs and no run state is saved. | `false` |
| `--file` | Path to workflow.json. | `.asc/workflow.json` |
| `--resume` | Resume a prior workflow run by run ID. Cannot be combined with `--dry-run` or with `KEY:VALUE` params. | — |

```sh
asc workflow run beta GROUP_ID:abcdef
```

### workflow validate

Checks the file's structure, references, cycles, output declarations and retry and timeout settings, without running anything. Prints `{"valid":true}`, or `valid: false` with an `errors` list, and then exits non-zero.

| Flag | What it does | Default |
| --- | --- | --- |
| `--file` | Path to workflow.json. | `.asc/workflow.json` |

`--output` only accepts `json` here.

```sh
asc workflow validate --file ./.asc/workflow.json
```

### workflow list

Lists the workflows in the file, sorted by name, each with `name`, `description` and `step_count`. Private workflows are left out unless `--all` is set; they are then marked `private`.

| Flag | What it does | Default |
| --- | --- | --- |
| `--all` | Include private workflows in listing. | `false` |
| `--file` | Path to workflow.json. | `.asc/workflow.json` |

```sh
asc workflow list --all
```

## webhooks

Every subcommand and flag: [asc webhooks](https://air.build/docs/cli/asc-webhooks/).

Manage webhooks in App Store Connect.

| Subcommand | What it does | Main flags |
| --- | --- | --- |
| [list](https://air.build/docs/cli/asc-webhooks/#list) | List webhooks for an app. | `--app` |
| [view](https://air.build/docs/cli/asc-webhooks/#view) | View a webhook by ID. | `--webhook-id` |
| [create](https://air.build/docs/cli/asc-webhooks/#create) | Create a webhook. | `--app`, `--enabled`, `--events`, `--name`, `--secret`, `--url` |
| [update](https://air.build/docs/cli/asc-webhooks/#update) | Update a webhook. | `--enabled`, `--events`, `--name`, `--secret`, `--url`, `--webhook-id` |
| [delete](https://air.build/docs/cli/asc-webhooks/#delete) | Delete a webhook. | `--confirm`, `--webhook-id` |
| [serve](https://air.build/docs/cli/asc-webhooks/#serve) | Run a local webhook receiver for testing and automation. | `--allow-remote`, `--dir`, `--exec`, `--host`, `--max-body-bytes`, `--port` |
| [deliveries](https://air.build/docs/cli/asc-webhooks/#deliveries) | List webhook deliveries. | `--created-after`, `--created-before`, `--webhook-id`; subcommands: `links`, `redeliver` |
| [ping](https://air.build/docs/cli/asc-webhooks/#ping) | Create a webhook ping. | `--webhook-id` |

`webhooks serve` listens on `127.0.0.1:8787` by default and prints text output. Binding to another host needs `--allow-remote`. `--dir` writes each event to a JSON file, and `--exec` runs a command per event with the payload on stdin. Bodies above `--max-body-bytes` are refused.

## xcode-cloud

Every subcommand and flag: [asc xcode-cloud](https://air.build/docs/cli/asc-xcode-cloud/).

Trigger and monitor Xcode Cloud workflows.

| Subcommand | What it does | Main flags |
| --- | --- | --- |
| `run` | Trigger an Xcode Cloud workflow build. | `--app`, `--branch`, `--clean`, `--doctor`, `--git-reference-id`, `--poll-interval`, `--pull-request-id`, `--source-run-id`, `--timeout`, `--wait`, `--workflow`, `--workflow-id` |
| `status` | Check the status of an Xcode Cloud build run. | `--poll-interval`, `--run-id`, `--timeout`, `--wait` |
| `doctor` | Diagnose an Xcode Cloud build run and inspect failure logs. | `--poll-interval`, `--run-id`, `--save-logs`, `--skip-logs`, `--timeout`, `--wait` |
| `products` | Manage Xcode Cloud products. | `--app`, `--include`, `--primary-repositories-limit`, `--product-type`; subcommands: `list`, `view`, `app`, `build-runs`, `workflows`, `primary-repositories`, `additional-repositories`, `delete` |
| `workflows` | Manage Xcode Cloud workflows. | `--app`; subcommands: `list`, `view`, `repository`, `create`, `update`, `duplicate`, `delete` |
| `scm` | Manage Xcode Cloud SCM providers and repositories. | subcommands: `providers`, `repositories`, `git-references`, `pull-requests` |
| `build-runs` | Manage Xcode Cloud build runs. | `--sort`, `--workflow-id`; subcommands: `list`, `view`, `builds` |
| `actions` | Manage build actions for an Xcode Cloud build run. | `--run-id`; subcommands: `list`, `view`, `build-run` |
| `artifacts` | Manage Xcode Cloud build artifacts. | subcommands: `list`, `view`, `download` |
| `test-results` | List Xcode Cloud test results. | subcommands: `list`, `view` |
| `issues` | List Xcode Cloud build issues. | subcommands: `list`, `view` |
| `macos-versions` | Manage Xcode Cloud macOS versions. | subcommands: `list`, `view`, `xcode-versions` |
| `xcode-versions` | Manage Xcode Cloud Xcode versions. | subcommands: `list`, `view`, `macos-versions` |

`xcode-cloud run` takes the workflow by name with `--app`, or by `--workflow-id`, and the source as `--branch` (branch or tag), `--git-reference-id` or `--pull-request-id`. `--source-run-id` reruns an earlier build run instead. With `--wait` it polls every `--poll-interval` (default `10s`) until the run ends or `--timeout` is reached (`0` means `ASC_TIMEOUT`, otherwise 30 minutes). Adding `--doctor` returns the doctor report; a failed build is then reported in the output and does not make the command exit non-zero.

Xcode Cloud usage, shared environment variables and settings such as the next build number are under `asc web xcode-cloud` (see [asc: web session commands](https://air.build/docs/cli/asc-web/)).

## notify

Send notifications to external services.

| Subcommand | What it does |
| --- | --- |
| [notify slack](https://air.build/docs/cli/asc-automation/#notify-slack) | Send a message to Slack via webhook. |

### notify slack

Posts a message to a Slack incoming webhook. Prints `Message sent to Slack successfully` on stderr and nothing on stdout. With `--read-only` or `ASC_READ_ONLY`, the message is refused before it is sent.

| Flag | What it does | Default |
| --- | --- | --- |
| `--blocks-file` | Path to a Slack Block Kit JSON array file. | — |
| `--blocks-json` | Slack Block Kit JSON array. | — |
| `--channel` | Slack channel override (`#channel` or `@username`). Slack may ignore it for incoming webhooks, depending on the Slack app's settings. | — |
| `--message` | Message to send to Slack. Required. | — |
| `--payload-file` | Path to a JSON object file of release fields, shown as Slack attachment fields. | — |
| `--payload-json` | JSON object of release fields to include as Slack attachment fields. | — |
| `--pretext` | Text shown above the attachment fields. | — |
| `--success` | Attachment color: success (`true`) or failure (`false`). | `true` |
| `--thread-ts` | Parent message timestamp (`thread_ts`) to post a threaded reply, such as `1733977745.12345`. | — |
| `--webhook` | Slack incoming webhook URL (or `ASC_SLACK_WEBHOOK`). Required. | — |

Notes:

- The webhook URL must be a Slack incoming webhook (`https://hooks.slack.com/...` or `https://hooks.slack-gov.com/...`). Pass it with `@env:NAME` or `ASC_SLACK_WEBHOOK` rather than as plain text: the URL is the secret.
- Give at most one of `--blocks-json` and `--blocks-file`, and at most one of `--payload-json` and `--payload-file`. Keep `--message` as the fallback text when you send blocks.
- `--pretext` and `--success` need `--payload-json` or `--payload-file`.
- For `--thread-ts`, take the parent message's `ts` from Slack's APIs or events; posting to a webhook only returns `ok`.

```sh
asc notify slack --webhook @env:SLACK_WEBHOOK_URL --message "Release submitted" \
  --payload-json '{"version":"1.2.3","build":"42"}' --pretext "App Store submission"
```

## migrate

Migrate metadata from and to the fastlane `deliver` layout.

| Subcommand | What it does |
| --- | --- |
| [migrate import](https://air.build/docs/cli/asc-automation/#migrate-import) | Import metadata from fastlane directory structure. |
| [migrate export](https://air.build/docs/cli/asc-automation/#migrate-export) | Export metadata to fastlane directory structure. |
| [migrate validate](https://air.build/docs/cli/asc-automation/#migrate-validate) | Validate fastlane metadata without uploading. |

The layout `migrate` reads and writes:

```text
fastlane/
├── Deliverfile
├── metadata/
│   ├── en-US/
│   │   ├── name.txt              (App Info)
│   │   ├── subtitle.txt          (App Info)
│   │   ├── privacy_url.txt       (App Info)
│   │   ├── description.txt       (version)
│   │   ├── keywords.txt          (version)
│   │   ├── release_notes.txt     (version)
│   │   ├── promotional_text.txt  (version)
│   │   ├── support_url.txt       (version)
│   │   ├── marketing_url.txt     (version)
│   │   └── app_clip/
│   │       ├── subtitle.txt
│   │       └── header_image.png
│   ├── review_information/
│   │   ├── first_name.txt, last_name.txt, email_address.txt, phone_number.txt
│   │   ├── demo_user.txt, demo_password.txt, demo_required.txt
│   │   └── notes.txt
│   └── app_clip/action.txt
├── app_previews/
│   └── en-US/
│       └── iphone_65/
│           ├── preview.mp4
│           └── preview.poster_frame.txt
└── screenshots/
    └── en-US/
        ├── iphone_65_1.png
        └── ...
```

### migrate import

Uploads the version's localized metadata, App Info localizations, review information, screenshots, app previews and App Clip metadata from a fastlane directory to App Store Connect. Prints a JSON plan or result: the app and version IDs, the directories it read, the locales, the files per locale, the screenshot plan, skipped items, and what was uploaded.

| Flag | What it does | Default |
| --- | --- | --- |
| `--allow-external-metadata` | Trust Deliverfile metadata paths and symlinks outside the selected fastlane directory. | `false` |
| `--allow-external-screenshots` | Trust Deliverfile screenshot paths and symlinks outside the selected fastlane directory. | `false` |
| `--allow-symlinked-deliverfile` | Trust and follow a symlinked Deliverfile. | `false` |
| `--app` | The app ID (or `ASC_APP_ID`, or the Deliverfile's `app_identifier`). Required. | — |
| `--check-remote` | Compare with what is in App Store Connect during a dry run, still without writing. Needs `--dry-run`. | `false` |
| `--confirm` | Confirm uploading the imported metadata, screenshots and assets. Required unless `--dry-run`. | `false` |
| `--dry-run` | Preview changes without uploading. | `false` |
| `--fastlane-dir` | Path to the fastlane directory. Without it, the Deliverfile's paths or the `metadata/` and `screenshots/` directories in the current directory are used. | — |
| `--include-sensitive` | Print secret values such as demo account passwords instead of `(redacted)`, for this run only. | `false` |
| `--skip-app-clip` | Skip App Clip metadata and header images. | `false` |
| `--skip-previews` | Skip app preview videos. | `false` |
| `--skip-screenshots` | Skip screenshot discovery and upload. | `false` |
| `--version-id` | App Store version ID. Required unless the Deliverfile sets `app_version` and `platform`. | — |

Notes:

- A dry run lists local inputs without contacting App Store Connect; add `--check-remote` to compare them with what is there, which may download delivered media.
- The `screenshots` directory must exist unless you pass `--skip-screenshots`; `skip_metadata` and `skip_screenshots` in the Deliverfile are honored.
- App previews are checked with `ffprobe` (from FFmpeg), which must be on `PATH`. App Clip header images must be PNG at 1800 x 1200.

```sh
asc migrate import --app "1234567890" --version-id "VERSION_ID" --fastlane-dir ./fastlane --dry-run --check-remote
```

### migrate export

Writes an App Store version's metadata to a fastlane directory: the version's text files and the App Info `name.txt`, `subtitle.txt` and `privacy_url.txt` for each locale (empty fields make no file), plus App Clip and app preview assets. Existing files are overwritten. Prints `versionId`, `outputDir`, `locales`, `totalFiles` and `assetFiles`; if an asset fails, `status` is `partial` with the reason in `failure`.

| Flag | What it does | Default |
| --- | --- | --- |
| `--app` | The app ID (or `ASC_APP_ID`). Required. | — |
| `--output-dir` | Output directory for the fastlane structure. Required. | — |
| `--version-id` | App Store version ID. Required. | — |

```sh
asc migrate export --app "1234567890" --version-id "VERSION_ID" --output-dir ./fastlane
```

### migrate validate

Checks fastlane metadata on this machine, without calling Apple: character limits, locales that `migrate import` can't create, and the App Clip header image and app previews (needs `ffprobe`, as for import; a bad asset stops the command with exit `1`). Prints `fastlaneDir`, `locales`, an `issues` list (locale, field, severity, message, and the length and limit where one is exceeded), `skipped` (when any), `errorCount`, `warnCount` and `valid`. An empty description is a warning. The command exits `0` even when `valid` is `false`, so check `valid` in scripts.

| Flag | What it does | Default |
| --- | --- | --- |
| `--allow-external-metadata` | Trust a metadata symlink outside the selected fastlane directory. | `false` |
| `--fastlane-dir` | Path to the fastlane directory. Required. | — |

```sh
asc migrate validate --fastlane-dir ./fastlane --output table
```

## Examples

Validate and dry-run a workflow, then run it:

```bash
asc workflow validate
asc workflow run --dry-run beta
asc workflow run beta GROUP_ID:"GROUP_ID"
```

Start an Xcode Cloud build and wait for the result with a diagnosis:

```bash
asc xcode-cloud run --app "1234567890" --workflow "CI" --branch "main" --wait --doctor
```

Import fastlane metadata, checking first:

```bash
asc migrate validate --fastlane-dir ./fastlane
asc migrate import --app "1234567890" --version-id "VERSION_ID" --fastlane-dir ./fastlane --dry-run --check-remote
asc migrate import --app "1234567890" --version-id "VERSION_ID" --fastlane-dir ./fastlane --confirm
```

Post to Slack when a release is submitted:

```bash
asc notify slack --webhook @env:SLACK_WEBHOOK_URL --message "Version 1.2.3 submitted for review"
```
