Skip to content

Commit 11433d0

Browse files
ci: extract reusable actions and workflows
Extracts screenshot setup and publishing logic into reusable GitHub Actions components. This adds composite actions for macOS screen-recording permissions and Windows tray/notification setup, introduces a reusable `_publish-screenshots.yml` workflow with inputs (artifact prefix, source run, screenshot branch), and updates `ci.yml` and `publish-screenshots.yml` to call these shared pieces. The result reduces duplication and makes screenshot publishing more configurable and easier to maintain.
1 parent 1d0d696 commit 11433d0

5 files changed

Lines changed: 522 additions & 427 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
name: Configure macOS screen recording
3+
description: Configure a GitHub-hosted macOS runner for tray screenshots and UI automation.
4+
5+
runs:
6+
using: composite
7+
steps:
8+
- name: Configure macOS screen recording
9+
shell: bash
10+
run: |
11+
set -euo pipefail
12+
13+
brew install cliclick
14+
clickTool="$(command -v cliclick)"
15+
16+
configure_system_tccdb() {
17+
local values=$1
18+
local dbPath="/Library/Application Support/com.apple.TCC/TCC.db"
19+
local sqlQuery="INSERT OR IGNORE INTO access VALUES($values);"
20+
sudo sqlite3 -cmd ".timeout 30000" "$dbPath" "$sqlQuery"
21+
}
22+
23+
configure_user_tccdb() {
24+
local values=$1
25+
local dbPath="$HOME/Library/Application Support/com.apple.TCC/TCC.db"
26+
local sqlQuery="INSERT OR IGNORE INTO access VALUES($values);"
27+
sqlite3 -cmd ".timeout 30000" "$dbPath" "$sqlQuery"
28+
}
29+
30+
systemValuesArray=(
31+
"'kTCCServiceScreenCapture','/bin/bash',1,2,0,1,NULL,NULL,NULL,'UNUSED',NULL,0,1599831148"
32+
"'kTCCServicePostEvent','/bin/bash',1,2,0,1,NULL,NULL,NULL,'UNUSED',NULL,0,1599831148"
33+
"'kTCCServicePostEvent','$clickTool',1,2,0,1,NULL,NULL,NULL,'UNUSED',NULL,0,1599831148"
34+
)
35+
for values in "${systemValuesArray[@]}"; do
36+
configure_system_tccdb "$values,NULL,NULL,'UNUSED',${values##*,}"
37+
done
38+
39+
userValuesArray=(
40+
"'kTCCServiceScreenCapture','/bin/bash',1,2,0,1,NULL,NULL,NULL,'UNUSED',NULL,0,1583997993"
41+
"'kTCCServicePostEvent','/bin/bash',1,2,0,1,NULL,NULL,NULL,'UNUSED',NULL,0,1583997993"
42+
"'kTCCServicePostEvent','$clickTool',1,2,0,1,NULL,NULL,NULL,'UNUSED',NULL,0,1583997993"
43+
)
44+
for values in "${userValuesArray[@]}"; do
45+
configure_user_tccdb "$values,NULL,NULL,'UNUSED',${values##*,}"
46+
done
47+
48+
preflightScreenshot="$RUNNER_TEMP/screen-capture-preflight.png"
49+
screencapture -x "$preflightScreenshot"
50+
sleep 1
51+
"$clickTool" kp:return
52+
sleep 1
53+
54+
echo "macOS screen recording configured."
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
name: Configure Windows tray screenshots
3+
description: Configure a GitHub-hosted Windows runner for visible tray icons and notifications.
4+
5+
runs:
6+
using: composite
7+
steps:
8+
- name: Configure Windows tray screenshots
9+
shell: pwsh
10+
run: |
11+
echo "::group::Enable all tray icons"
12+
$trayIconScript = Join-Path $env:RUNNER_TEMP "Enable-AllTrayIcons.ps1"
13+
Invoke-WebRequest `
14+
-Uri "https://raw.githubusercontent.com/paulmann/windows-show-all-tray-icons/main/Enable-AllTrayIcons.ps1" `
15+
-OutFile $trayIconScript
16+
& $trayIconScript -Action Enable -Force
17+
echo "::endgroup::"
18+
19+
echo "::group::Disable Do Not Disturb"
20+
Add-Type -AssemblyName System.Windows.Forms
21+
Start-Process "ms-settings:notifications"
22+
Start-Sleep -Seconds 2
23+
[System.Windows.Forms.SendKeys]::SendWait("{TAB}")
24+
[System.Windows.Forms.SendKeys]::SendWait("{TAB}")
25+
[System.Windows.Forms.SendKeys]::SendWait(" ")
26+
echo "::endgroup::"
27+
28+
echo "::group::Minimize all windows"
29+
$shell = New-Object -ComObject Shell.Application
30+
$shell.MinimizeAll()
31+
echo "::endgroup::"
32+
33+
echo "::group::Set Date - Hack for Quiet Time"
34+
$newDate = (Get-Date).AddHours(2)
35+
Set-Date -Date $newDate
36+
echo "::endgroup::"

0 commit comments

Comments
 (0)