Build and Deploy Examples #182
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: Build and Deploy Examples | |
| on: workflow_dispatch | |
| env: | |
| COMMIT_SHORT_SHA: ${{ github.sha }} | |
| jobs: | |
| build_expo: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Get short commit SHA | |
| run: echo "COMMIT_SHORT_SHA=${GITHUB_SHA:0:7}" >> $GITHUB_ENV | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Install Dependencies | |
| run: | | |
| yarn | |
| yarn bootstrap | |
| - name: Build All Packages | |
| run: yarn build | |
| - name: Build Expo Example | |
| run: EXPO_PUBLIC_COMMIT_SHA=${{ env.COMMIT_SHORT_SHA }} yarn expo export:web | |
| working-directory: packages/connect-examples/expo-example | |
| - name: Add commit info to build output | |
| run: | | |
| # 先备份原始构建产物到临时目录 | |
| mkdir -p temp-build | |
| cp -r web-build/* temp-build/ 2>/dev/null || true | |
| # 创建带有 commit id 的子目录 | |
| mkdir -p web-build/commits/${{ env.COMMIT_SHORT_SHA }} | |
| # 复制备份的构建产物到带有 commit id 的目录 | |
| cp -r temp-build/* web-build/commits/${{ env.COMMIT_SHORT_SHA }}/ | |
| # 创建一个 commit 信息文件 | |
| echo '{"commit": "${{ env.COMMIT_SHORT_SHA }}", "fullCommit": "${{ github.sha }}", "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' > web-build/commits/${{ env.COMMIT_SHORT_SHA }}/commit-info.json | |
| # 为 commit 版本也创建 404.html | |
| cp web-build/commits/${{ env.COMMIT_SHORT_SHA }}/index.html web-build/commits/${{ env.COMMIT_SHORT_SHA }}/404.html | |
| # 清理临时目录 | |
| rm -rf temp-build | |
| working-directory: packages/connect-examples/expo-example | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: expo-build | |
| path: packages/connect-examples/expo-example/web-build |