# Send Slack Alerts for iOS CI Build Status

Canonical: https://figment.so/blog/mac-ci-slack-notification-build-status

Create a Slack incoming webhook, store it as a CI secret, and call a Fastlane notify_slack lane (or slackapi/slack-github-action) with if: always() so the message posts on success and failure.

**Create a Slack incoming webhook, store the URL as a CI secret, and post from a Fastlane `notify_slack` lane or from `slackapi/slack-github-action` in a step that runs `if: always()`.** A useful message carries four fields: status, branch, commit author and a link to the run or artifact. This guide builds a lane on the [Fastlane slack action](https://docs.fastlane.tools/actions/slack/) and a GitHub Actions alternative using Slack's [incoming webhooks](https://docs.slack.dev/messaging/sending-messages-using-incoming-webhooks).

The Slack step runs after the build, so it lives on whichever Mac runner builds and signs your app.

## Why post build status to Slack?

The result arrives in the channel the team already watches. Dashboard-first feedback forces developers to notice a badge, click to the CI URL, then read the log. Signal quality matters more than volume: `Build failed · feature/payment-refactor · alex · IPA: not produced` is actionable, and a bare red X is not.

## How do I create a Slack incoming webhook?

Create one per channel. Slack incoming webhooks are per-app and post to a fixed channel chosen at install time. Per [Slack's docs](https://docs.slack.dev/messaging/sending-messages-using-incoming-webhooks), you cannot override the destination channel, username, or icon at post time.

1. Open [api.slack.com/apps](https://api.slack.com/apps) and create (or reuse) an app.
2. Under **Features → Incoming Webhooks**, toggle on.
3. Click **Add New Webhook to Workspace** and pick the channel.
4. Copy the URL (`https://hooks.slack.com/services/T.../B.../XXX`).

Store it in your CI secret manager (GitHub Actions: **Settings → Secrets and variables → Actions**, name `SLACK_WEBHOOK_URL`). Never paste the raw URL into a committed workflow or Fastfile, because Slack revokes leaked webhooks.

## What should the message contain?

Five fields, mapped to GitHub Actions context:

| Field | Value | Source |
|---|---|---|
| Status | success / failure | `job.status` |
| Branch | `main`, `feature/...` | `github.ref_name` |
| Commit author | GitHub username | `github.actor` |
| Commit SHA | short hash | `github.sha` (first 7) |
| Artifact link | workflow run URL | `${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` |

For TestFlight uploads, link App Store Connect's TestFlight page for the app and include the workflow run URL as a fallback, so the message is still useful if the upload step failed.

## How do I write a reusable notify_slack Fastlane lane?

Add this lane to `fastlane/Fastfile`. It reads inputs from env vars, so the same lane works in GitHub Actions, Bitrise, Buildkite, or Jenkins:

```ruby
# fastlane/Fastfile (inside platform :ios do ... end)

lane :notify_slack do |options|
  build_ok = options.key?(:success) ? options[:success] :
             (ENV.fetch("FASTLANE_LANE_SUCCESS", "false") == "true")
  branch    = ENV.fetch("GITHUB_REF_NAME",  "unknown-branch")
  actor     = ENV.fetch("GITHUB_ACTOR",     "unknown")
  run_url   = ENV.fetch("WORKFLOW_RUN_URL", "")
  sha_short = ENV.fetch("GITHUB_SHA", "")[0, 7]

  status_emoji = build_ok ? ":white_check_mark:" : ":x:"
  status_text  = build_ok ? "Build succeeded"    : "Build FAILED"

  # Incoming webhooks post to the channel configured at install time;
  # do not pass :channel — it is ignored per Slack docs.
  slack(
    slack_url:        ENV.fetch("SLACK_WEBHOOK_URL"),
    message:          "#{status_emoji} *#{status_text}*",
    success:          build_ok,
    payload: {
      "Branch" => branch,
      "Author" => actor,
      "Commit" => sha_short,
      "Run"    => run_url
    },
    default_payloads: [],
    fail_on_error:    false
  )
end
```

Call it from your main lane with an `ensure` block so the alert fires even when an earlier step raises:

```ruby
lane :beta do
  build_ok = false
  begin
    match(type: "appstore", readonly: true)
    build_app(workspace: "ios/YourApp.xcworkspace", scheme: "YourApp")
    upload_to_testflight(skip_waiting_for_build_processing: true)
    build_ok = true
  ensure
    notify_slack(success: build_ok)
  end
end
```

Replace `YourApp.xcworkspace` and the scheme with your own project's values, and confirm the scheme in `xcodebuild -list`.

## How do I call the lane from GitHub Actions?

Add a final step with `if: always()`, so it runs on both success and failure:

```yaml
- name: Notify Slack
  if: always()
  run: bundle exec fastlane notify_slack
  env:
    SLACK_WEBHOOK_URL:     ${{ secrets.SLACK_WEBHOOK_URL }}
    GITHUB_REF_NAME:       ${{ github.ref_name }}
    GITHUB_ACTOR:          ${{ github.actor }}
    GITHUB_SHA:            ${{ github.sha }}
    WORKFLOW_RUN_URL:      ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
    FASTLANE_LANE_SUCCESS: ${{ job.status == 'success' && 'true' || 'false' }}
```

The lane reads `FASTLANE_LANE_SUCCESS` when it is not called directly from Ruby.

## How do I ping @channel only for failures on main?

Gate the broadcast mention on both conditions. A red build on `main` is urgent, and a red build on a feature branch usually is not.

```ruby
lane :notify_slack do |options|
  build_ok = options[:success]
  branch   = ENV.fetch("GITHUB_REF_NAME", "")
  mention  = (!build_ok && branch == "main") ? "<!channel> " : ""

  slack(
    slack_url: ENV.fetch("SLACK_WEBHOOK_URL"),
    message:   "#{mention}#{build_ok ? ':white_check_mark: Build succeeded' : ':x: Build FAILED'}",
    success:   build_ok,
    default_payloads: [],
    fail_on_error: false
  )
end
```

`<!channel>` is Slack's documented webhook syntax for a channel-wide mention. A literal `@channel` in a webhook payload does not notify.

## Can I post to Slack without Fastlane?

Yes. Use [`slackapi/slack-github-action`](https://github.com/slackapi/slack-github-action), which needs no Ruby on the runner:

```yaml
- name: Notify Slack (native)
  if: always()
  uses: slackapi/slack-github-action@v2
  with:
    webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
    webhook-type: incoming-webhook
    payload: |
      {
        "text": "${{ job.status == 'success' && ':white_check_mark: Build succeeded' || ':x: Build FAILED' }}",
        "attachments": [{
          "color": "${{ job.status == 'success' && 'good' || 'danger' }}",
          "fields": [
            { "title": "Branch", "value": "${{ github.ref_name }}", "short": true },
            { "title": "Author", "value": "${{ github.actor }}", "short": true },
            { "title": "Run",    "value": "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View>", "short": false }
          ]
        }]
      }
```

Use Fastlane when you already have a Fastfile, because `ensure` handles exceptions in one place.

## Does the runner need firewall changes?

Only if you control an egress firewall or proxy. The Slack call is an outbound HTTPS request to `hooks.slack.com:443`, so allow that host in your own proxy or allowlist.

## Which Figment Mac plan fits this work, and how does the price compare?

The notification is trivial, so pick the plan for the build. The [Apple Silicon Mac VM](/mac-hosting#apple-silicon-vm) runs current Xcode. The [Intel Mac VM](/mac-hosting#intel-vm) fits only when Xcode 26.3 or earlier on macOS Sequoia is enough. Use the [Dedicated M4 Pro 48 GB](/mac-hosting#dedicated-m4-pro) for parallel or heavy builds. You run your own CI and notification step.

Headline monthly prices on 2026-11-10 for comparable offers:

| Offer | Monthly | 12 months | Notes |
|---|---|---|---|
| Figment Apple Silicon Mac VM | $39 | 12 × $39 = $468 | 4 shared vCPUs, 4GB, 65GB |
| Figment Dedicated M4 Pro 48 GB | $349 | $3,228 paid up front | Whole Mac: M4 Pro, 48GB, 512GB |
| [CloudMac M4 / 16GB / 256GB](https://cloudmac.org/pricing) | $99.99 | [$999/year](https://cloudmac.org/) ≈ $83.25/month | 256GB row shows "Reserve now"; 512GB/1TB show "Fully reserved" |
| [MacStadium M4.S 16GB/256GB](https://macstadium.com/pricing) | $149 | multi-year via sales | 99.99% uptime claim and included support per that page |

The hardware differs, so compare specs before price. Figment's VM costs less per year than CloudMac's $999, but it is a shared 4GB VM, while the CloudMac listing is a whole 16GB Mac. If you need a whole Mac, the comparable Figment row is the Dedicated M4 Pro 48 GB, with 48GB and 512GB. Tax applies as stated in each provider's offer.

**Related guides:** [GitHub-hosted vs self-hosted Mac runner costs](/blog/mac-github-hosted-vs-self-hosted-cost) · [Speed up CI builds with a RAM disk on Mac](/blog/mac-ramdisk-derived-data-ci-speed) · [Remote Xcode setup on Windows](/blog/mac-xcode-on-windows-remote-setup)
