|
| 1 | +name: Deploy iOS demo app |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - 'release/**' |
| 8 | + |
| 9 | +# cancel previous workflow runs that are not completed yet |
| 10 | +# ref: https://github.com/TeamAmaze/AmazeFileManager/blob/release/3.7/.github/workflows/android-feature.yml#L10-L12 |
| 11 | +concurrency: |
| 12 | + group: deploy-ios-demo-app-${{ github.event.pull_request.number || github.ref }} |
| 13 | + cancel-in-progress: true |
| 14 | + |
| 15 | +jobs: |
| 16 | + deploy-ios-demo-app: |
| 17 | + timeout-minutes: 35 |
| 18 | + runs-on: [self-hosted] |
| 19 | + env: |
| 20 | + FL_OUTPUT_DIR: output |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v3 |
| 23 | + with: |
| 24 | + fetch-depth: 2 |
| 25 | + lfs: true |
| 26 | + |
| 27 | + - name: Create iOS config files |
| 28 | + env: |
| 29 | + IOS_FASTLANE_ENV: '${{ secrets.IOS_FASTLANE_ENV }}' |
| 30 | + APP_STORE_CONNECT_API_KEY_P8_APP_MANAGER: '${{ secrets.APP_STORE_CONNECT_API_KEY_P8_APP_MANAGER }}' |
| 31 | + run: | |
| 32 | + echo $IOS_FASTLANE_ENV | base64 --decode > ios/fastlane/.env.default |
| 33 | + echo $APP_STORE_CONNECT_API_KEY_P8_APP_MANAGER | base64 --decode > ios/fastlane/AuthKey_A9LPUK52N8.p8 |
| 34 | + - name: Dump Xcode path to check which version |
| 35 | + run: 'echo "Xcode path: $(xcode-select -p)"' # e.g. -> "Xcode path: /Applications/Xcode-14.2.0.app/Contents/Developer" |
| 36 | + |
| 37 | + # setup yarn |
| 38 | + - uses: actions/setup-node@v3 |
| 39 | + with: |
| 40 | + node-version-file: '.nvmrc' # ref: https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#node-version-file |
| 41 | + # cache: "yarn" |
| 42 | + - name: Dump node and yarn versions |
| 43 | + run: 'echo "node: $(node -v) yarn: $(yarn -v)"' |
| 44 | + - name: Install Dependencies |
| 45 | + run: yarn install --immutable --immutable-cache |
| 46 | + |
| 47 | + # 目前跑 Install Bundler 會失敗,先注解掉 |
| 48 | + # - name: Install bundler |
| 49 | + # run: gem install bundler:2.2.27 --user-install # bundler for our lockfile |
| 50 | + # working-directory: ios |
| 51 | + - name: Bundle Install |
| 52 | + run: bundle install |
| 53 | + working-directory: ios |
| 54 | + - name: Dump ruby and bundler version |
| 55 | + run: 'echo "ruby: $(ruby -v) bundler: $(bundle -v)"' |
| 56 | + working-directory: ios |
| 57 | + |
| 58 | + - name: Print app build-number |
| 59 | + run: bundle exec fastlane print_build_number |
| 60 | + working-directory: ios |
| 61 | + |
| 62 | + - name: Save PR_NUMBER to env |
| 63 | + run: | |
| 64 | + PR_NUMBER=$(gh pr view --json number -q .number) |
| 65 | + echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV |
| 66 | + continue-on-error: true |
| 67 | + - name: Replace patch with PR_NUMBER on version name |
| 68 | + if: ${{ env.PR_NUMBER != '' }} |
| 69 | + run: sed -i -e "/MARKETING_VERSION/ s/\(\.[0-9]*\)\..*/\1.${{ env.PR_NUMBER }};/" ios/CoolWalletAppDemo.xcodeproj/project.pbxproj |
| 70 | + - name: Deploy demo App to TestFlight |
| 71 | + run: bundle exec fastlane deploy_demo_app |
| 72 | + working-directory: ios |
| 73 | + |
| 74 | + - name: Send deployed message to Slack |
| 75 | + env: |
| 76 | + GITHUB_SECRET_SLACK_WEBHOOK_URL_COOLBITX_BOT: '${{ secrets.SLACK_WEBHOOK_URL_COOLBITX_BOT }}' |
| 77 | + run: bundle exec fastlane slack_deployed_message_for_demo_app |
| 78 | + working-directory: ios |
| 79 | + |
| 80 | + - name: Report error to Slack |
| 81 | + uses: 8398a7/action-slack@v3 |
| 82 | + with: |
| 83 | + status: ${{ job.status }} |
| 84 | + fields: repo,pullRequest,commit,author,job,took # selectable (default: repo,message) |
| 85 | + env: |
| 86 | + SLACK_WEBHOOK_URL: '${{ secrets.SLACK_WEBHOOK_URL_COOLBITX_BOT }}' |
| 87 | + if: ${{ failure() }} |
0 commit comments