Guide

How to set up a self-hosted macOS runner for GitHub Actions

A step-by-step guide to running GitHub Actions jobs on your own dedicated Mac: from a fresh Mac mini to a runner service that builds and tests your Xcode project on every pull request, with caching, code signing and security covered.

13 min readLast updated:

Why self-host a macOS runner

GitHub offers hosted macOS runners that start a clean virtual machine for every job. They work well, but they are billed per minute, start without your caches and run on images you do not control. A self-hosted runner is a Mac you register with GitHub yourself. It picks up jobs from your repositories and runs them on hardware nobody else uses.

A self-hosted Mac makes sense when

  • You build often and want a fixed monthly cost instead of per-minute billing for macOS jobs.
  • Builds spend a lot of time on resolving packages and compiling from scratch. A persistent Mac keeps DerivedData and Swift Package Manager caches between runs.
  • You want to decide when Xcode and macOS are updated, not follow a vendor image schedule.
  • Your source code and build artifacts should stay on a machine in an EU datacenter.

GitHub-hosted runners are fine when

  • You run a handful of macOS builds per week and the included minutes cover them.
  • You need a clean, throwaway machine for every job, for example on a public repository.
  • You need many short jobs in parallel at peak times and nothing in between.
  • Nobody on the team wants to maintain a macOS machine.

What you need

  • A Mac on Apple silicon with SSH access. This guide uses a dedicated Mac mini M6 running macOS Tahoe 26.
  • Admin rights on a GitHub repository, or owner rights on an organization if you want to share the runner between repositories.
  • An Apple Account to download Xcode, and your signing certificates if the workflow signs builds.
  • Outbound HTTPS (port 443) from the Mac to GitHub. The runner connects out to GitHub, so no inbound port has to be opened for it.
1

Step 1

Order a dedicated Mac

In the configurator choose a model, the macOS version and the datacenter. macOS Tahoe 26 is the default, Sequoia is available if your Xcode version needs it. Pick a datacenter close to your team and your Git hosting: Amsterdam or Naaldwijk in the Netherlands, or Frankfurt in Germany.

Most Macs are online by the next business day; at times of high demand it can take longer. You then receive the IP addresses (public IPv4 and IPv6) and admin login for the Mac.

2

Step 2

Connect over SSH and lock it down

Log in with the admin account and confirm you are on the expected machine.

Terminal
ssh <ADMIN_USER>@<YOUR_MAC_IP>

# Confirm the machine and macOS version
sw_vers
uname -m        # arm64 on Apple silicon

Copy your public key to the Mac first (for example with ssh-copy-id) and test that key login works. Then switch off password logins and turn on the application firewall.

Terminal
# Key-only SSH: add your public key first, then disable passwords
sudo tee /etc/ssh/sshd_config.d/100-ci.conf >/dev/null <<'EOF'
PasswordAuthentication no
KbdInteractiveAuthentication no
EOF
sudo launchctl kickstart -k system/com.openssh.sshd

# Turn on the macOS application firewall
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on
3

Step 3

Create a dedicated runner user

Run the runner under its own standard (non-admin) macOS user. A job then cannot change system settings, and the runner's files, keychain and caches are separated from your admin account.

Terminal (admin)
# Create a standard (non-admin) user; "-password -" asks for the password interactively
sudo sysadminctl -addUser runner -fullName "GitHub Actions runner" -password -

# Let the runner user use developer tools (debugging, UI tests) without admin rights
sudo dseditgroup -o edit -a runner -t user _developer
sudo DevToolsSecurity -enable

# Only needed if Remote Login is limited to specific users
sudo dseditgroup -o edit -a runner -t user com.apple.access_ssh

# Reuse your SSH key for the runner user
sudo mkdir -p /Users/runner/.ssh
sudo cp ~/.ssh/authorized_keys /Users/runner/.ssh/authorized_keys
sudo chown -R runner:staff /Users/runner/.ssh
sudo chmod 700 /Users/runner/.ssh
sudo chmod 600 /Users/runner/.ssh/authorized_keys
4

Step 4

Install Xcode and accept the license

Install Xcode with your admin account. On a headless server the command line is easier than the App Store. Both options below need an Apple Account; xcodes also lets you keep several Xcode versions side by side.

Terminal (admin)
# Option A: xcodes (asks for your Apple Account to download)
brew install xcodesorg/made/xcodes
xcodes install --latest --select

# Option B: a .xip downloaded from developer.apple.com/download
xip --expand Xcode_<VERSION>.xip
sudo mv Xcode.app /Applications/Xcode.app

Then select the Xcode version, accept the license and let Xcode install its additional components. xcodebuild -runFirstLaunch does what the first launch of the Xcode app would do, so a CI job does not stop on it.

Terminal (admin)
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -license accept
sudo xcodebuild -runFirstLaunch

# Simulator runtime for iOS tests
xcodebuild -downloadPlatform iOS

# Check the result
xcodebuild -version
xcrun simctl list runtimes
5

Step 5

Download and register the runner

In GitHub open Settings > Actions > Runners > New self-hosted runner in your repository (or in your organization to share it). Select macOS and ARM64. GitHub shows the exact download URL, checksum and a registration token. Copy the commands from that page rather than from a guide: the runner version changes regularly and the token is short-lived.

Terminal (runner user)
# Run as the runner user: ssh runner@<YOUR_MAC_IP>
mkdir -p ~/actions-runner && cd ~/actions-runner

# Paste the download, checksum and extract commands from
# Settings > Actions > Runners > New self-hosted runner (macOS, ARM64).
# They look like this, with the current version filled in:
curl -o actions-runner-osx-arm64-<VERSION>.tar.gz -L \
  https://github.com/actions/runner/releases/download/v<VERSION>/actions-runner-osx-arm64-<VERSION>.tar.gz
echo "<SHA256>  actions-runner-osx-arm64-<VERSION>.tar.gz" | shasum -a 256 -c
tar xzf ./actions-runner-osx-arm64-<VERSION>.tar.gz

Register the runner with the URL and token from the same page. --unattended skips the prompts, --name is what you see in GitHub and --labels adds custom labels next to the default ones.

Terminal (runner user)
./config.sh \
  --url https://github.com/<OWNER>/<REPO> \
  --token <REGISTRATION_TOKEN> \
  --name mac-m6-01 \
  --labels xcode-26 \
  --work _work \
  --unattended

The runner gets the default labels self-hosted, macOS and ARM64 automatically. Custom labels can only be set at registration with config.sh; to change them later use the GitHub UI or API. The GitHub documentation on self-hosted runners describes all options.

6

Step 6

Run the runner as a service

Instead of keeping ./run.sh open in a terminal, install the runner as a launchd service for the runner user, so it starts again after a reboot. On macOS the commands run without sudo.

Terminal (runner user)
cd ~/actions-runner
./svc.sh install
./svc.sh start
./svc.sh status

# Later: ./svc.sh stop and ./svc.sh uninstall

In GitHub the runner should now show as Idle. Reboot the Mac once through SSH or the remote power control and check that it comes back by itself.

7

Step 7

Point a workflow at the runner

A job lands on your Mac when every label in runs-on matches the runner. This workflow builds and tests an Xcode project on every pull request and on pushes to main, and cancels older runs for the same branch.

.github/workflows/ios.yml
name: iOS CI

on:
  pull_request:
  push:
    branches: [main]

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  build-and-test:
    runs-on: [self-hosted, macOS, ARM64]
    timeout-minutes: 60
    env:
      DEVELOPER_DIR: /Applications/Xcode.app/Contents/Developer
    steps:
      - uses: actions/checkout@v4

      - name: Show toolchain
        run: xcodebuild -version

      - name: Build and test
        run: |
          set -o pipefail
          xcodebuild test \
            -project MyApp.xcodeproj \
            -scheme MyApp \
            -destination 'platform=iOS Simulator,name=iPhone 17' \
            -derivedDataPath "$HOME/ci-cache/DerivedData/${{ github.event.repository.name }}" \
            -clonedSourcePackagesDirPath "$HOME/ci-cache/SourcePackages/${{ github.event.repository.name }}" \
            -resultBundlePath TestResults.xcresult

      - name: Upload test results
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: test-results
          path: TestResults.xcresult
  • Replace MyApp.xcodeproj and MyApp with your project and scheme, or use -workspace MyApp.xcworkspace for a workspace.
  • Use a simulator that exists on the Mac. xcrun simctl list devices available shows the names.
  • Pin actions to a major version (or a commit SHA) and update them deliberately.
  • timeout-minutes stops a hung build from blocking the runner for hours.
8

Step 8

Keep caches warm

A persistent Mac does not need to download caches at the start of every job: they are already on disk. The workflow above stores DerivedData and resolved Swift packages under ~/ci-cache, per repository, outside the workspace that actions/checkout cleans.

  • DerivedData: incremental builds reuse compiled modules. Keep one path per repository so projects do not invalidate each other.
  • Swift Package Manager: -clonedSourcePackagesDirPath keeps checked-out packages, so resolving is mostly a version check.
  • CocoaPods and Homebrew: their caches live in the runner user's home folder and persist by default.

Caches grow. Clean them on a schedule so the disk does not fill up halfway through a build.

crontab (runner user)
# Example: weekly cleanup as the runner user (crontab -e)
# Removes DerivedData folders not touched for 14 days and unavailable simulators
0 3 * * 0  find "$HOME/ci-cache/DerivedData" -mindepth 1 -maxdepth 1 -mtime +14 -exec rm -rf {} +
15 3 * * 0 xcrun simctl delete unavailable
9

Step 9

Code signing on the runner

Tests on the simulator do not need signing. For archives and TestFlight uploads the runner needs a certificate and provisioning profile. Do not put them in the runner user's login keychain by hand; use a keychain per job or a tool that does this for you.

Option A: fastlane match. Certificates and profiles live encrypted in a private Git repository or cloud storage. setup_ci creates a temporary keychain and match installs into it, read-only.

fastlane/Fastfile
# fastlane/Fastfile
lane :ci_build do
  setup_ci                          # temporary keychain for this run
  match(type: "appstore", readonly: true)
  build_app(scheme: "MyApp")
end

Option B: a CI keychain from secrets. Store the .p12 (base64) and its password as GitHub Actions secrets and create a temporary keychain in the job. set-key-partition-list prevents the "codesign wants to access key" prompt that would otherwise hang the build.

Workflow step (shell)
# Inside a job, before signing. Values come from GitHub Actions secrets.
KEYCHAIN="$RUNNER_TEMP/ci.keychain-db"
security create-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN"
security set-keychain-settings -lut 21600 "$KEYCHAIN"
security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN"

echo "$SIGNING_CERT_P12_BASE64" | base64 --decode > "$RUNNER_TEMP/cert.p12"
security import "$RUNNER_TEMP/cert.p12" -k "$KEYCHAIN" -P "$SIGNING_CERT_PASSWORD" -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" "$KEYCHAIN"
security list-keychains -d user -s "$KEYCHAIN" $(security list-keychains -d user | tr -d '"')

# After the job (in an "if: always()" step):
# security delete-keychain "$KEYCHAIN"

For uploads to App Store Connect, prefer an App Store Connect API key over an Apple Account password with two-factor authentication.

Security checklist

  • Limit who can run workflows. Use branch protection and required reviews for changes to .github/workflows. For organization runners, use runner groups to decide which repositories may use the Mac.
  • Do not run untrusted fork pull requests. Keep fork workflows off the self-hosted runner, or require approval for outside contributors.
  • Assume jobs can leave things behind. A self-hosted runner is not a fresh VM. Clean up in an if: always() step or with job hooks, and never pass secrets as command-line arguments, where other processes can read them.
  • Standard user, not admin. The runner user from step 3 has no sudo rights. Keep it that way.
  • Firewall and SSH. The runner needs outbound HTTPS only. Keep inbound access to SSH with keys, and restrict it further to your office or VPN IP addresses if you can.
  • Updates. The runner application updates itself by default. Install macOS security updates with softwareupdate, and test new Xcode versions on a branch before switching the default.

Job hooks run a script before and after every job, which is a convenient place to remove leftover files, simulators or keychains.

~/actions-runner/.env
# ~/actions-runner/.env  (restart the service after editing)
ACTIONS_RUNNER_HOOK_JOB_STARTED=/Users/runner/ci-hooks/job-started.sh
ACTIONS_RUNNER_HOOK_JOB_COMPLETED=/Users/runner/ci-hooks/job-completed.sh

Scaling to more runners and Macs

One runner runs one job at a time. When jobs start to queue, you have two options.

  • More Macs (recommended for Xcode). Register each Mac with the same labels. GitHub hands the next job to whichever matching runner is idle, and builds do not compete for CPU, memory or disk.
  • A second runner on one Mac. Possible on a Mac with more memory, but parallel Xcode builds and simulators compete for resources. Measure first, and give each runner its own directory and cache paths.
Terminal (runner user)
# A second runner on the same Mac needs its own directory and name
mkdir -p ~/actions-runner-2 && cd ~/actions-runner-2
# download and extract the runner again, then:
./config.sh --url https://github.com/<OWNER> --token <REGISTRATION_TOKEN> \
  --name mac-m6-01-b --labels xcode-26 --unattended
./svc.sh install && ./svc.sh start

For several repositories, register the runners at organization level and use runner groups to control access. Labels such as xcode-26 or ui-tests let workflows pick the right machine as the fleet grows.

Troubleshooting

Start with the service status and the runner logs in the _diag folder.

Terminal (runner user)
cd ~/actions-runner
./svc.sh status
ls -t _diag/ | head          # newest Runner_*.log and Worker_*.log files
tail -n 100 "_diag/$(ls -t _diag | grep Runner_ | head -1)"
  • Runner shows as Offline. Check ./svc.sh status and the newest Runner_*.log. After a reboot, make sure the runner user is logged in automatically. A runner that has not connected for more than 14 days is removed by GitHub and needs to be registered again with a new token.
  • "You have not agreed to the Xcode license agreements". Run sudo xcodebuild -license accept with the admin account. This is needed again after every Xcode update.
  • Build hangs at code signing, or `errSecInternalComponent`. The keychain is locked or the key is missing its partition list. Unlock the keychain in the job and run security set-key-partition-list as shown in step 9.
  • "Unable to find a destination". The simulator name or runtime does not exist. Check xcrun simctl list devices available and install the runtime with xcodebuild -downloadPlatform iOS.
  • Disk full. Remove old DerivedData folders and unavailable simulators, and check ~/Library/Developer/Xcode/Archives and ~/Library/Developer/CoreSimulator.
  • The Mac does not respond at all. Use the remote power control to restart it, or the JetKVM console to see what is on the screen.
FAQ

Questions about self-hosted macOS runners

Short answers to what teams usually ask before moving macOS jobs to their own Mac.

At the time of writing GitHub lists self-hosted runner usage as free: jobs on your own runner do not use the per-minute macOS rate. Check GitHub's billing documentation for the current terms. You pay for the Mac itself, at a fixed monthly price.

A macOS runner on Apple silicon gets the default labels self-hosted, macOS and ARM64, so runs-on: [self-hosted, macOS, ARM64] works out of the box. Add custom labels such as xcode-26 at registration to target specific machines.

One runner process runs one job at a time. You can install a second runner in its own directory, but parallel Xcode builds compete for CPU, memory and disk. For predictable build times, add another Mac with the same labels.

GitHub advises against it, because pull requests from anyone could run code on your Mac. Use self-hosted runners for private repositories and keep public projects on GitHub-hosted runners.

Install the new version next to the current one (for example with xcodes), accept the license and run xcodebuild -runFirstLaunch. Test it on a branch by setting DEVELOPER_DIR in that workflow, then switch the default once it builds.

No. The runner makes outbound HTTPS connections to GitHub on port 443. The only inbound access you need is SSH for administration, which you can restrict to keys and known IP addresses.

Run your macOS jobs on your own Mac

A dedicated Mac mini M6 or M5 Pro in the Netherlands or Germany, with SSH access and a fixed monthly price.

  • 10 Gigabit Ethernet port, 1 Gbit/s unmetered, public IPv4 and IPv6
  • macOS Tahoe 26 by default, Sequoia available
  • Remote power control included, JetKVM console optional