mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
Add GitHub Actions workflow for building Dashboard iOS Wrapper
This commit is contained in:
154
.github/workflows/dashboard-ios.yaml
vendored
Normal file
154
.github/workflows/dashboard-ios.yaml
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
name: Build Dashboard iOS Wrapper
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
pwa_origin:
|
||||
description: "Origin that serves the Dashboard (used to resolve relative asset paths)"
|
||||
required: false
|
||||
default: "https://app.oneuptime.com"
|
||||
package_id:
|
||||
description: "iOS bundle identifier (reverse DNS style)"
|
||||
required: false
|
||||
default: "com.oneuptime.dashboard"
|
||||
host_name:
|
||||
description: "Host name for entitlement allow list (optional)"
|
||||
required: false
|
||||
default: "app.oneuptime.com"
|
||||
|
||||
jobs:
|
||||
build-ios:
|
||||
runs-on: macos-latest
|
||||
env:
|
||||
MANIFEST_SOURCE_PATH: Dashboard/public/manifest.json
|
||||
PWA_ORIGIN: ${{ inputs.pwa_origin }}
|
||||
PACKAGE_ID: ${{ inputs.package_id }}
|
||||
HOST_NAME: ${{ inputs.host_name }}
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Compute version numbers
|
||||
id: version
|
||||
run: |
|
||||
set -euo pipefail
|
||||
VERSION_PREFIX=$(cat VERSION_PREFIX | tr -d ' \n')
|
||||
VERSION_NAME="${VERSION_PREFIX}.${GITHUB_RUN_NUMBER}"
|
||||
echo "name=${VERSION_NAME}" >> $GITHUB_OUTPUT
|
||||
echo "code=${GITHUB_RUN_NUMBER}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Extract manifest metadata
|
||||
id: manifest
|
||||
run: |
|
||||
set -euo pipefail
|
||||
node <<'NODE' > manifest.outputs
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const manifestPath = path.join(process.env.GITHUB_WORKSPACE, process.env.MANIFEST_SOURCE_PATH);
|
||||
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
||||
const origin = process.env.PWA_ORIGIN;
|
||||
const start = manifest.start_url || '/dashboard/';
|
||||
const startUrl = new URL(start, origin).toString();
|
||||
const appName = manifest.name || manifest.short_name || 'OneUptime';
|
||||
const shortName = manifest.short_name || manifest.name || 'OneUptime';
|
||||
const themeColor = manifest.theme_color || '#000000';
|
||||
const entries = {
|
||||
app_name: appName,
|
||||
short_name: shortName,
|
||||
start_url: startUrl,
|
||||
theme_color: themeColor
|
||||
};
|
||||
const escape = (value) => String(value)
|
||||
.replace(/%/g, '%25')
|
||||
.replace(/\r/g, '%0D')
|
||||
.replace(/\n/g, '%0A');
|
||||
for (const [key, value] of Object.entries(entries)) {
|
||||
console.log(`${key}=${escape(value)}`);
|
||||
}
|
||||
NODE
|
||||
cat manifest.outputs >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install CocoaPods
|
||||
run: |
|
||||
sudo gem install cocoapods --no-document
|
||||
|
||||
- name: Scaffold Capacitor iOS project
|
||||
env:
|
||||
APP_NAME: ${{ steps.manifest.outputs.app_name }}
|
||||
SHORT_NAME: ${{ steps.manifest.outputs.short_name }}
|
||||
START_URL: ${{ steps.manifest.outputs.start_url }}
|
||||
THEME_COLOR: ${{ steps.manifest.outputs.theme_color }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
WORK_DIR=ios-wrapper
|
||||
rm -rf "$WORK_DIR"
|
||||
mkdir "$WORK_DIR"
|
||||
cd "$WORK_DIR"
|
||||
npm init -y >/dev/null 2>&1
|
||||
npm install @capacitor/cli@5 @capacitor/core@5 >/dev/null 2>&1
|
||||
mkdir -p www
|
||||
cat <<'HTML' > www/index.html
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>OneUptime Wrapper</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
<style>body{font-family:system-ui, sans-serif;display:flex;align-items:center;justify-content:center;height:100vh;margin:0;background:#f5f5f5;color:#333}.
|
||||
notice{max-width:480px;text-align:center;padding:1rem}</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="notice">
|
||||
<h1>Building iOS shell…</h1>
|
||||
<p>The production build loads the live PWA at runtime.</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
HTML
|
||||
npx cap init "$APP_NAME" "$PACKAGE_ID" --web-dir=www --skip-appid-validation
|
||||
rm -f capacitor.config.ts
|
||||
if [[ "${START_URL}" == http:* ]]; then
|
||||
CLEAR=true
|
||||
else
|
||||
CLEAR=false
|
||||
fi
|
||||
cat <<JSON > capacitor.config.json
|
||||
{
|
||||
"appId": "${PACKAGE_ID}",
|
||||
"appName": "${APP_NAME}",
|
||||
"webDir": "www",
|
||||
"bundledWebRuntime": false,
|
||||
"server": {
|
||||
"url": "${START_URL}",
|
||||
"cleartext": ${CLEAR}
|
||||
},
|
||||
"plugins": {
|
||||
"SplashScreen": {
|
||||
"launchShowDuration": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
JSON
|
||||
npx cap add ios
|
||||
npx cap sync ios
|
||||
cd ios/App
|
||||
/usr/libexec/PlistBuddy -c "Set :CFBundleDisplayName ${SHORT_NAME}" App/App-Info.plist
|
||||
/usr/libexec/PlistBuddy -c "Set :CFBundleName ${SHORT_NAME}" App/App-Info.plist
|
||||
|
||||
- name: Package Xcode project
|
||||
run: |
|
||||
set -euo pipefail
|
||||
cd ios-wrapper
|
||||
zip -r ../dashboard-ios-project.zip ios >/dev/null
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: dashboard-ios-project-${{ steps.version.outputs.name }}
|
||||
path: dashboard-ios-project.zip
|
||||
Reference in New Issue
Block a user