|
| 1 | +name: "build-example-ios-for-pr" |
| 2 | + |
| 3 | +on: |
| 4 | + issue_comment: |
| 5 | + types: [created] |
| 6 | + |
| 7 | +jobs: |
| 8 | + build: |
| 9 | + name: Build Example App for Specific PR |
| 10 | + runs-on: macos-14 |
| 11 | + |
| 12 | + # Only run if its a PR and the comment contains: |
| 13 | + # "run-workflow:build-example-ios-for-pr" |
| 14 | + if: github.event.issue.pull_request && contains(github.event.comment.body, 'run-workflow:build-example-ios-for-pr') |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Cancel previous runs |
| 18 | + uses: styfle/cancel-workflow-action@0.9.1 |
| 19 | + |
| 20 | + - name: Get branch of PR |
| 21 | + uses: xt0rted/pull-request-comment-branch@v1 |
| 22 | + id: comment-branch |
| 23 | + |
| 24 | + - name: Checkout PR branch ${{ steps.comment-branch.outputs.head_ref }} |
| 25 | + uses: actions/checkout@v3 |
| 26 | + with: |
| 27 | + ref: ${{ steps.comment-branch.outputs.head_ref }} |
| 28 | + |
| 29 | + - name: Add workflow link as comment on PR |
| 30 | + uses: actions/github-script@v6 |
| 31 | + if: always() |
| 32 | + with: |
| 33 | + script: | |
| 34 | + const name = '${{ github.workflow }}'; |
| 35 | + const url = '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'; |
| 36 | + const body = `Run GH Workflow: ${name}`; |
| 37 | +
|
| 38 | + await github.rest.issues.createComment({ |
| 39 | + issue_number: context.issue.number, |
| 40 | + owner: context.repo.owner, |
| 41 | + repo: context.repo.repo, |
| 42 | + body: body |
| 43 | + }) |
| 44 | +
|
| 45 | + # Start build... |
| 46 | + |
| 47 | + - name: Show self-hosted machine infomation |
| 48 | + run: uname -a |
| 49 | + |
| 50 | + - name: Check Xcode version |
| 51 | + run: /usr/bin/xcodebuild -version |
| 52 | + |
| 53 | + - name: Checkout repo from main branch |
| 54 | + uses: actions/checkout@v4 |
| 55 | + |
| 56 | + - name: Install Apple certificate and provisioning profile |
| 57 | + env: |
| 58 | + BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }} |
| 59 | + P12_PASSWORD: ${{ secrets.P12_PASSWORD }} |
| 60 | + BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }} |
| 61 | + KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} |
| 62 | + run: | |
| 63 | + # create variables |
| 64 | + CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12 |
| 65 | + PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision |
| 66 | + KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db |
| 67 | +
|
| 68 | + # import certificate and provisioning profile from secrets |
| 69 | + echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH |
| 70 | + echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o $PP_PATH |
| 71 | +
|
| 72 | + # create temporary keychain |
| 73 | + security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH |
| 74 | + security set-keychain-settings -lut 21600 $KEYCHAIN_PATH |
| 75 | + security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH |
| 76 | +
|
| 77 | + # import certificate to keychain |
| 78 | + security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH |
| 79 | + security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH |
| 80 | + security list-keychain -d user -s $KEYCHAIN_PATH |
| 81 | +
|
| 82 | + # apply provisioning profile |
| 83 | + mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles |
| 84 | + cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles |
| 85 | +
|
| 86 | + - uses: actions/setup-node@v4 |
| 87 | + with: |
| 88 | + node-version: 'v18.12.1' |
| 89 | + cache: 'yarn' |
| 90 | + |
| 91 | + - name: Initialize library |
| 92 | + run: | |
| 93 | + yarn install |
| 94 | + cd example |
| 95 | + yarn install |
| 96 | +
|
| 97 | + - name: Build JS |
| 98 | + run: yarn run bob build |
| 99 | + |
| 100 | + - name: 1/4 - Run `pod-install` (fabric, static library) |
| 101 | + run: yarn pod-install:new-static |
| 102 | + |
| 103 | + - name: 1/4 - Build example (fabric, static library) |
| 104 | + run: yarn run build:ios |
| 105 | + |
| 106 | + - name: Clear/reset example pods |
| 107 | + run: yarn run nuke:example-pods |
| 108 | + |
| 109 | + - name: 2/4 - Run `pod-install` (fabric, dynamic frameworks) |
| 110 | + run: yarn pod-install:new-dynamic |
| 111 | + |
| 112 | + - name: 2/4 - Build example (fabric, dynamic frameworks) |
| 113 | + run: yarn run build:ios |
| 114 | + |
| 115 | + - name: Clear/reset example pods |
| 116 | + run: yarn run nuke:example-pods |
| 117 | + |
| 118 | + - name: 3/4 - Run `pod-install` (paper, static library) |
| 119 | + run: yarn pod-install:old-static |
| 120 | + |
| 121 | + - name: 3/4 - Build example (paper, static library) |
| 122 | + run: yarn run build:ios |
| 123 | + |
| 124 | + - name: Clear/reset example pods |
| 125 | + run: yarn run nuke:example-pods |
| 126 | + |
| 127 | + - name: 4/4 - Run `pod-install` (paper, dynamic frameworks) |
| 128 | + run: yarn pod-install:old-dynamic |
| 129 | + |
| 130 | + - name: 4/4 - Build example (paper, dynamic frameworks) |
| 131 | + run: yarn run build:ios |
| 132 | + |
0 commit comments