ci: introduce self host runner (#3237)

* ci: test self host runner

* update

* update

* push

* prefer self then github

* update

* log

* update

* update

* update

* update

* update

* try label

* Revert "try label"

This reverts commit 05d19cf24f760df39cb1c739e2b0ee073368137b.

* include build mac

* try hyoban to build mac

* update

* update

* update

* update

* push

* push

* push

* push

* push

* push

* try

* try

* Revert "try"

This reverts commit c1be653a93a87bfa14c6cfc7fb2e8ba20ae39bf4.

* fix build

* add runner

* Revert "add runner"

This reverts commit 70e0c357467d118bf2b28c1d979f5fc43cf2793a.

* clean

* avoid setup on self host

* update
This commit is contained in:
Stephen Zhou 2025-03-23 17:21:59 +08:00 committed by GitHub
parent e7e4031381
commit 2f8f13738c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 51 additions and 11 deletions

View File

@ -2,13 +2,13 @@ name: Build iOS IPA for development
on:
push:
branches: [dev, main]
branches: [dev]
paths:
- "apps/mobile/web-app/**"
- "apps/mobile/native/**"
- "apps/mobile/package.json"
pull_request:
branches: [dev, main]
branches: [dev]
paths:
- "apps/mobile/web-app/**"
- "apps/mobile/native/**"
@ -19,18 +19,38 @@ concurrency:
cancel-in-progress: true
jobs:
check-runner:
runs-on: ubuntu-latest
outputs:
runner-label: ${{ steps.set-runner.outputs.runner-label }}
steps:
- name: Set runner
id: set-runner
run: |
runners=$(curl -s -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.RUNNER_GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/actions/runners")
available=$(echo "$runners" | jq '.runners[] | select(.status == "online" and .busy == false and .labels[] .name == "self-hosted")')
if [ -n "$available" ]; then
echo "runner-label=self-hosted" >> $GITHUB_OUTPUT
else
echo "runner-label=macos-latest" >> $GITHUB_OUTPUT
fi
build:
name: Build iOS IPA for device
runs-on: macos-latest
needs: check-runner
runs-on: ${{ needs.check-runner.outputs.runner-label }}
steps:
- name: 📦 Checkout code
uses: actions/checkout@v4
- name: 📦 Setup pnpm
if: needs.check-runner.outputs.runner-label == 'macos-latest'
uses: pnpm/action-setup@v4
- name: 🏗 Setup Node.js
if: needs.check-runner.outputs.runner-label == 'macos-latest'
uses: actions/setup-node@v4
with:
node-version: 22

View File

@ -26,18 +26,38 @@ concurrency:
cancel-in-progress: true
jobs:
check-runner:
runs-on: ubuntu-latest
outputs:
runner-label: ${{ steps.set-runner.outputs.runner-label }}
steps:
- name: Set runner
id: set-runner
run: |
runners=$(curl -s -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.RUNNER_GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/actions/runners")
available=$(echo "$runners" | jq '.runners[] | select(.status == "online" and .busy == false and .labels[] .name == "self-hosted")')
if [ -n "$available" ]; then
echo "runner-label=self-hosted" >> $GITHUB_OUTPUT
else
echo "runner-label=macos-latest" >> $GITHUB_OUTPUT
fi
build:
name: Build iOS IPA
runs-on: macos-latest
needs: check-runner
runs-on: ${{ needs.check-runner.outputs.runner-label }}
steps:
- name: 📦 Checkout code
uses: actions/checkout@v4
- name: 📦 Setup pnpm
if: needs.check-runner.outputs.runner-label == 'macos-latest'
uses: pnpm/action-setup@v4
- name: 🏗 Setup Node.js
if: needs.check-runner.outputs.runner-label == 'macos-latest'
uses: actions/setup-node@v4
with:
node-version: 22

View File

@ -126,13 +126,13 @@ jobs:
cd apps/desktop
pnpm update:main-hash
- name: Build
if: matrix.os != 'macos-latest'
if: runner.os != 'macOS'
run: pnpm build:electron
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
- name: Build (macOS)
if: matrix.os == 'macos-latest' && github.event.inputs.mas != 'true'
if: runner.os == 'macOS' && github.event.inputs.mas != 'true'
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
@ -146,7 +146,7 @@ jobs:
command: pnpm build:macos
- name: Build (Mac App Store)
if: matrix.os == 'macos-latest' && github.event.inputs.mas == 'true'
if: runner.os == 'macOS' && github.event.inputs.mas == 'true'
env:
OSX_SIGN_KEYCHAIN_PATH: ${{ runner.temp }}/app-signing.keychain-db
OSX_SIGN_IDENTITY: ${{ secrets.OSX_SIGN_IDENTITY_MAS }}
@ -155,7 +155,7 @@ jobs:
run: pnpm build:mas
- name: Build Renderer
if: matrix.os == 'ubuntu-latest'
if: runner.os == 'Linux'
run: pnpm build:render
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
@ -181,7 +181,7 @@ jobs:
- name: Upload file (arm64.dmg)
uses: actions/upload-artifact@v4
if: matrix.os == 'macos-latest'
if: runner.os == 'macOS'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
@ -192,7 +192,7 @@ jobs:
- name: Upload file (pkg)
uses: actions/upload-artifact@v4
if: matrix.os == 'macos-latest'
if: runner.os == 'macOS'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:

View File

@ -8,9 +8,9 @@
"bump": "vv",
"db:generate": "drizzle-kit generate",
"dev": "npm run start",
"eas-build-post-install": "rm -rf $TMPDIR/metro-cache",
"ios": "expo run:ios",
"ios:device": "expo run:ios --device",
"lint": "expo lint",
"start": "expo start --dev-client",
"start:clean": "expo start --dev-client --clear",
"typecheck": "tsc --noEmit",