name: Mobile Auto Deploy on: pull_request: types: [closed] branches: [staging] paths: - "app/**" - "!app/**/*.md" - "!app/docs/**" - "packages/mobile-sdk-alpha/**" concurrency: group: mobile-deploy-${{ github.ref }} cancel-in-progress: false permissions: contents: write pull-requests: write id-token: write jobs: check-and-deploy: # WORKFLOW DISABLED # Maybe it's my understanding, but it doesn't work as expected. disabled for now. if: false # if: github.event.pull_request.merged == true && !contains(github.event.pull_request.labels.*.name, 'deploy:skip') runs-on: ubuntu-latest outputs: should_deploy: ${{ steps.check.outputs.should_deploy }} deployment_track: ${{ steps.check.outputs.deployment_track }} version_bump: ${{ steps.check.outputs.version_bump }} platforms: ${{ steps.check.outputs.platforms }} steps: - name: Check deployment conditions id: check run: | echo "๐Ÿ” Checking deployment conditions..." # Skip if PR has deploy:skip label labels="${{ join(github.event.pull_request.labels.*.name, ',') }}" if [[ "$labels" =~ deploy:skip ]]; then echo "should_deploy=false" >> $GITHUB_OUTPUT echo "โญ๏ธ Skipping deployment due to deploy:skip label" exit 0 fi # Determine deployment track based on target branch if [[ "${{ github.base_ref }}" == "main" ]]; then echo "deployment_track=production" >> $GITHUB_OUTPUT echo "๐Ÿš€ Deployment track: production" elif [[ "${{ github.base_ref }}" == "staging" ]]; then echo "deployment_track=internal" >> $GITHUB_OUTPUT echo "๐Ÿงช Deployment track: internal testing" fi # Determine version bump from PR labels labels="${{ join(github.event.pull_request.labels.*.name, ',') }}" if [[ "$labels" =~ version:major ]]; then echo "version_bump=major" >> $GITHUB_OUTPUT echo "๐Ÿ“ˆ Version bump: major" elif [[ "$labels" =~ version:minor ]]; then echo "version_bump=minor" >> $GITHUB_OUTPUT echo "๐Ÿ“ˆ Version bump: minor" elif [[ "$labels" =~ version:patch ]] || [[ "${{ github.base_ref }}" == "main" ]]; then echo "version_bump=patch" >> $GITHUB_OUTPUT echo "๐Ÿ“ˆ Version bump: patch" else echo "version_bump=build" >> $GITHUB_OUTPUT echo "๐Ÿ“ˆ Version bump: build only" fi # Determine platforms based on deploy labels # If both deploy:ios and deploy:android labels exist, deploy both # If neither label exists, deploy both (default behavior) # If only one label exists, deploy only that platform has_ios_label=false has_android_label=false if [[ "$labels" =~ deploy:ios ]]; then has_ios_label=true fi if [[ "$labels" =~ deploy:android ]]; then has_android_label=true fi if [[ "$has_ios_label" == "true" && "$has_android_label" == "true" ]]; then echo 'platforms=["ios", "android"]' >> $GITHUB_OUTPUT echo "๐Ÿ“ฑ Deploying both iOS and Android (both labels present)" elif [[ "$has_ios_label" == "true" ]]; then echo 'platforms=["ios"]' >> $GITHUB_OUTPUT echo "๐Ÿ“ฑ Deploying iOS only (deploy:ios label present)" elif [[ "$has_android_label" == "true" ]]; then echo 'platforms=["android"]' >> $GITHUB_OUTPUT echo "๐Ÿ“ฑ Deploying Android only (deploy:android label present)" else echo 'platforms=["ios", "android"]' >> $GITHUB_OUTPUT echo "๐Ÿ“ฑ Deploying both iOS and Android (no platform labels, default behavior)" fi echo "should_deploy=true" >> $GITHUB_OUTPUT - name: Log deployment info if: steps.check.outputs.should_deploy == 'true' run: | echo "๐Ÿ“ฑ Auto-deployment triggered!" echo "Branch: ${{ github.base_ref }}" echo "Track: ${{ steps.check.outputs.deployment_track }}" echo "Version bump: ${{ steps.check.outputs.version_bump }}" echo "PR: #${{ github.event.pull_request.number }} - ${{ github.event.pull_request.title }}" echo "Merged by: ${{ github.event.pull_request.merged_by.login }}" deploy-ios: needs: check-and-deploy if: needs.check-and-deploy.outputs.should_deploy == 'true' && contains(fromJson(needs.check-and-deploy.outputs.platforms), 'ios') uses: ./.github/workflows/mobile-deploy.yml with: platform: ios deployment_track: ${{ needs.check-and-deploy.outputs.deployment_track }} version_bump: ${{ needs.check-and-deploy.outputs.version_bump }} auto_deploy: true test_mode: true secrets: inherit deploy-android: needs: check-and-deploy if: needs.check-and-deploy.outputs.should_deploy == 'true' && contains(fromJson(needs.check-and-deploy.outputs.platforms), 'android') uses: ./.github/workflows/mobile-deploy.yml with: platform: android deployment_track: ${{ needs.check-and-deploy.outputs.deployment_track }} version_bump: ${{ needs.check-and-deploy.outputs.version_bump }} auto_deploy: true test_mode: true secrets: inherit notify-skip: needs: check-and-deploy if: needs.check-and-deploy.outputs.should_deploy == 'false' runs-on: ubuntu-latest steps: - name: Notify skip run: | echo "๐Ÿ“ฑ Mobile deployment was skipped for this PR" echo "To deploy manually, use the 'Run workflow' button on the Mobile App Deployments workflow"