Last active
June 8, 2025 19:31
-
-
Save YOU54F/3ac099e54e48a31a69ac2d671aa878f6 to your computer and use it in GitHub Desktop.
Run GitHub Actions projects, locally, using on MacOS ARM64 Virtual Machines with Tart
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
#!/bin/bash | |
PROJECT=${PWD##*/} | |
PLATFORM=${PLATFORM:-macos-latest} | |
WORKFLOW=${WORKFLOW:-test.yml} | |
IMAGE=${IMAGE:-runner} | |
SSH_USER=${SSH_USER:-runner} | |
SSH_PASS=${SSH_PASS:-runner} | |
# IMAGE=${IMAGE:-ghcr.io/cirruslabs/macos-ventura-xcode:14.3.1} | |
function cleanup { | |
echo "Cleaning up..." | |
tart stop "$PROJECT" || echo 'failed to stop' | |
if [[ -z ${KEEP} ]]; then | |
echo "cleaning vm $PROJECT" | |
tart delete "$PROJECT" || echo 'failed to delete' | |
set +e | |
tart list | grep "$PROJECT" && echo failed to cleanup && exit 1 | |
else | |
echo retaining vm "$PROJECT" | |
fi | |
} | |
trap cleanup EXIT | |
set -e # always ensure our trap runs | |
echo "Running for project $PROJECT" | |
if [[ ${PLATFORM} =~ "macos" ]]; then | |
tart clone "$IMAGE" "$PROJECT" | |
tart list | grep "$PROJECT" | |
tart get "$PROJECT" | |
tart run "$PROJECT" --dir="${PROJECT}:$PWD" --no-graphics & | |
echo "Waiting for VM to start..." | |
tart ip "$PROJECT" --wait 60 | |
tart get "$PROJECT" | |
passh -p $SSH_PASS ssh $SSH_USER@"$(tart ip "$PROJECT")" -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=accept-new -t "source ~/.zprofile && brew install act" | |
set +e | |
passh -p $SSH_PASS ssh $SSH_USER@"$(tart ip "$PROJECT")" -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=accept-new -t "source ~/.zprofile && cd /Volumes/My\ Shared\ files/${PWD##*/} && act -P ${PLATFORM}=-self-hosted -W ${WORKFLOW} $*" | |
ACT_EXIT_CODE=$? | |
set -e | |
fi | |
if [[ ${ACT_EXIT_CODE} != "" ]]; then | |
echo $ACT_EXIT_CODE | |
exit $ACT_EXIT_CODE | |
else | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run GitHub Actions projects, locally, using on MacOS ARM64 Virtual Machines
pre reqs
brew install act
inside the runnerusage
Drop into an project with a GitHub workflow with a
macos-latest
runnerUse the following env vars to control stuff
TODO
curl https://github.com/you54f.keys | tee -a ~/.ssh/authorized_keys