Skip to content

Commit

Permalink
ci: add action to access CI server over VNC
Browse files Browse the repository at this point in the history
  • Loading branch information
kmontag committed Aug 19, 2024
1 parent 52437dc commit ed20bbc
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/macos_vnc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# From https://github.com/vnc-tools/debug-on-mac.
#
# macos_vnc.sh VNC_USER_PASSWORD VNC_PASSWORD NGROK_AUTH_TOKEN

# Disable spotlight indexing
sudo mdutil -i off -a

# Create new account
sudo dscl . -create /Users/vncuser
sudo dscl . -create /Users/vncuser UserShell /bin/bash
sudo dscl . -create /Users/vncuser RealName "VNC User"
sudo dscl . -create /Users/vncuser UniqueID 1001
sudo dscl . -create /Users/vncuser PrimaryGroupID 80
sudo dscl . -create /Users/vncuser NFSHomeDirectory /Users/vncuser
sudo dscl . -passwd /Users/vncuser $1
sudo dscl . -passwd /Users/vncuser $1
sudo createhomedir -c -u vncuser >/dev/null

# Enable VNC
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -configure -allowAccessFor -allUsers -privs -all
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -configure -clientopts -setvnclegacy -vnclegacy yes

# Set VNC password
# This sets the password directly in the preferences file becuase MacOS 10.14
# and later does not allows control the Screen Sharing without using the UI
# See: # http://hints.macworld.com/article.php?story=20071103011608872
echo $2 | perl -we 'BEGIN { @k = unpack "C*", pack "H*", "1734516E8BA8C5E2FF1C39567390ADCA"}; $_ = <>; chomp; s/^(.{8}).*/$1/; @p = unpack "C*", $_; foreach (@k) { printf "%02X", $_ ^ (shift @p || 0) }; print "\n"' | sudo tee /Library/Preferences/com.apple.VNCSettings.txt

# Start VNC/reset changes
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -restart -agent -console
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate

# Install ngrok
brew install --cask ngrok

# Configure ngrok and start it
ngrok authtoken $3
ngrok tcp 5900 &
50 changes: 50 additions & 0 deletions .github/workflows/macos_vnc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# From https://github.com/vnc-tools/debug-on-mac.
#
# Set up the server for a VNC connection via ngrok.
name: macos_vnc
on:
workflow_dispatch:
inputs:
vnc_user_password:
description: Password for the created user (vncuser)
required: true

defaults:
run:
shell: bash

jobs:
build:
runs-on: macos-13
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up environment
env:
NGROK_AUTH_TOKEN: ${{ secrets.NGROK_AUTH_TOKEN }}
VNC_USER_PASSWORD: ${{ github.event.inputs.vnc_user_password }}
VNC_PASSWORD: ${{ github.event.inputs.vnc_user_password }}
run: source .github/macos_vnc.sh "$VNC_USER_PASSWORD" "$VNC_PASSWORD" "$NGROK_AUTH_TOKEN"

- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master

- name: Install Ableton Live
run: brew install --cask ableton-live-lite

- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.8
cache: pip

- run: python -m pip install poetry
- run: poetry install

- name: ngrok is now listening to VNC connections on...
run: curl --silent http://127.0.0.1:4040/api/tunnels | jq '.tunnels[0].public_url'

- name: Setup tmate session
uses: mxschmitt/action-tmate@v2

0 comments on commit ed20bbc

Please sign in to comment.