re: Add mac action (Porentially fix pathing) #3
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
name: Test Build VBA (macOS) | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- mac | |
permissions: | |
id-token: write | |
attestations: write | |
jobs: | |
build: | |
runs-on: macos-latest | |
steps: | |
- name: "Checkout" | |
uses: actions/checkout@v4 | |
- name: "Install Office" | |
run: | | |
# macOS Office installers: https://github.com/alsyundawy/Microsoft-Office-For-MacOS | |
# Download the Office installer from: https://go.microsoft.com/fwlink/?linkid=525133 | |
curl -L "https://go.microsoft.com/fwlink/?linkid=525133" -o microsoft_office_installer.pkg | |
# Create a choices XML file to disable Microsoft AutoUpdate and suppress dialogs | |
cat > choices.xml << EOF | |
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<array> | |
<dict> | |
<key>choiceAttribute</key> | |
<string>customLocation</string> | |
<key>attributeSetting</key> | |
<string>/Applications</string> | |
<key>choiceIdentifier</key> | |
<string>com.microsoft.autoupdate</string> | |
</dict> | |
<dict> | |
<key>choiceAttribute</key> | |
<string>visible</string> | |
<key>attributeSetting</key> | |
<false/> | |
<key>choiceIdentifier</key> | |
<string>com.microsoft.autoupdate</string> | |
</dict> | |
</array> | |
</plist> | |
EOF | |
# Install Office using the choices file to suppress dialogs | |
sudo installer -pkg microsoft_office_installer.pkg -target / -applyChoiceChangesXML choices.xml | |
# Disable Microsoft AutoUpdate after installation | |
defaults write com.microsoft.autoupdate2 SendAllTelemetryEnabled -bool FALSE | |
defaults write com.microsoft.autoupdate2 DisableInsiderCheckbox -bool TRUE | |
defaults write com.microsoft.autoupdate2 HowToCheck -string "Manual" | |
shell: bash | |
- name: "Run Excel Macro" | |
run: | | |
# Debug: Show current directory and list contents of key directories | |
pwd | |
ls -la | |
ls -la tests/fixtures || echo "fixtures directory not found" | |
# Use repo-relative paths since we're in the repo root after checkout | |
WORKBOOK_PATH="./tests/fixtures/ExcelForMacWorkbook.xlsm" | |
APPLESCRIPT_PATH="./scripts/mac/run.applescript" | |
# Make sure the workbook exists | |
if [ ! -f "$WORKBOOK_PATH" ]; then | |
echo "Error: Excel workbook not found at $WORKBOOK_PATH" | |
ls -la "$(dirname "$WORKBOOK_PATH")" | |
exit 1 | |
fi | |
# Make sure the AppleScript exists | |
if [ ! -f "$APPLESCRIPT_PATH" ]; then | |
echo "Error: AppleScript not found at $APPLESCRIPT_PATH" | |
exit 1 | |
fi | |
# Get absolute paths for files (AppleScript needs absolute paths) | |
ABS_WORKBOOK_PATH="$(pwd)/$WORKBOOK_PATH" | |
ABS_APPLESCRIPT_PATH="$(pwd)/$APPLESCRIPT_PATH" | |
echo "Using workbook: $ABS_WORKBOOK_PATH" | |
echo "Using script: $ABS_APPLESCRIPT_PATH" | |
# Run the AppleScript to open Excel and execute the WriteToFile macro | |
osascript "$ABS_APPLESCRIPT_PATH" excel "$ABS_WORKBOOK_PATH" "WriteToFile" | |
# Display the output file to confirm the macro executed successfully | |
OUTPUT_DIR="$(dirname "$ABS_WORKBOOK_PATH")" | |
OUTPUT_FILE="$OUTPUT_DIR/ExcelForMacWorkbook.txt" | |
echo "Checking if output file was created:" | |
ls -l "$OUTPUT_FILE" || echo "Output file not found" | |
if [ -f "$OUTPUT_FILE" ]; then | |
echo "Content of output file:" | |
cat "$OUTPUT_FILE" | |
fi | |
shell: bash | |
- name: "Take exiting screenshot" | |
if: always() | |
run: | | |
mkdir -p screenshots | |
screencapture -x screenshots/$(date +%Y%m%d_%H%M%S).png | |
shell: bash | |
- name: "Upload Screenshots" | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: "Screenshots" | |
path: "./screenshots/*" | |
if-no-files-found: warn |