|
| 1 | +name: Trigger Bitrise Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + # Only trigger when sample app or dependencies change |
| 8 | + - "sample/**" |
| 9 | + - "modules/**" |
| 10 | + - "package.json" |
| 11 | + - "yarn.lock" |
| 12 | + - ".github/workflows/trigger-bitrise-build.yml" |
| 13 | + |
| 14 | + workflow_dispatch: # Allow manual triggers |
| 15 | + |
| 16 | +jobs: |
| 17 | + trigger-bitrise: |
| 18 | + name: Trigger Bitrise Build |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - name: Trigger Bitrise Pipeline |
| 22 | + env: |
| 23 | + BITRISE_APP_SLUG: ${{ secrets.BITRISE_APP_SLUG }} |
| 24 | + BITRISE_API_TOKEN: ${{ secrets.BITRISE_API_TOKEN }} |
| 25 | + run: | |
| 26 | + echo "🚀 Triggering Bitrise build for React Native sample app..." |
| 27 | +
|
| 28 | + RESPONSE=$(curl -X POST \ |
| 29 | + "https://app.bitrise.io/app/$BITRISE_APP_SLUG/build/start.json" \ |
| 30 | + -H "Authorization: token $BITRISE_API_TOKEN" \ |
| 31 | + -H "Content-Type: application/json" \ |
| 32 | + -d @- <<EOF |
| 33 | + { |
| 34 | + "hook_info": { |
| 35 | + "type": "bitrise" |
| 36 | + }, |
| 37 | + "build_params": { |
| 38 | + "branch": "${{ github.ref_name }}", |
| 39 | + "commit_hash": "${{ github.sha }}", |
| 40 | + "commit_message": $(echo '${{ github.event.head_commit.message }}' | jq -Rs .), |
| 41 | + "workflow_id": "build_ios_sample_app" |
| 42 | + } |
| 43 | + } |
| 44 | + EOF |
| 45 | + ) |
| 46 | +
|
| 47 | + echo "Response: $RESPONSE" |
| 48 | +
|
| 49 | + # Extract build slug and URL |
| 50 | + BUILD_SLUG=$(echo "$RESPONSE" | jq -r '.build_slug // empty') |
| 51 | + BUILD_URL=$(echo "$RESPONSE" | jq -r '.build_url // empty') |
| 52 | +
|
| 53 | + if [ -n "$BUILD_SLUG" ]; then |
| 54 | + echo "✅ Bitrise build triggered successfully!" |
| 55 | + echo " Build URL: $BUILD_URL" |
| 56 | + echo " Build Slug: $BUILD_SLUG" |
| 57 | + else |
| 58 | + echo "❌ Failed to trigger Bitrise build" |
| 59 | + echo "$RESPONSE" |
| 60 | + exit 1 |
| 61 | + fi |
| 62 | +
|
| 63 | + - name: Comment on PR (if applicable) |
| 64 | + if: github.event_name == 'pull_request' |
| 65 | + uses: actions/github-script@v7 |
| 66 | + with: |
| 67 | + script: | |
| 68 | + github.rest.issues.createComment({ |
| 69 | + issue_number: context.issue.number, |
| 70 | + owner: context.repo.owner, |
| 71 | + repo: context.repo.name, |
| 72 | + body: '🚀 Bitrise build triggered for sample app changes.\n\n[View build on Bitrise](https://app.bitrise.io/build/${{ env.BUILD_SLUG }})' |
| 73 | + }) |
0 commit comments