-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (91 loc) · 3.04 KB
/
Copy pathtrigger-bitrise2.yml
File metadata and controls
107 lines (91 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: Android CI/CD via Bitrise
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
release:
types: [published]
jobs:
validate:
name: Validate Code
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Grant Permission to Execute Gradle
run: chmod +x ./gradlew
- name: Run Lint Checks
run: ./gradlew lint
continue-on-error: true
- name: Run Unit Tests
run: ./gradlew test
trigger-bitrise:
name: Trigger Bitrise Build
needs: validate
runs-on: ubuntu-latest
steps:
- name: Call Bitrise API to Start Build
run: |
BITRISE_BUILD_URL="https://api.bitrise.io/v0.1/apps/${{ secrets.BITRISE_APP_SLUG }}/builds"
curl -X POST "$BITRISE_BUILD_URL" \
-H "Authorization: Bearer ${{ secrets.BITRISE_API_TOKEN }}" \
-H "Content-Type: application/json" \
--data '{
"hook_info": { "type": "bitrise" },
"build_params": {
"branch": "main",
"workflow_id": "deploy"
},
"triggered_by": "GitHub Actions"
}'
- name: Wait for Bitrise Build to Complete
run: |
BITRISE_BUILD_URL="https://api.bitrise.io/v0.1/apps/${{ secrets.BITRISE_APP_SLUG }}/builds"
while true; do
RESPONSE=$(curl -s -H "Authorization: Token ${{ secrets.BITRISE_API_TOKEN }}" "$BITRISE_BUILD_URL")
echo "Bitrise API Response: $RESPONSE"
STATUS=$(echo "$RESPONSE" | jq -r '.data[].status_text')
if [[ -z "$STATUS" || "$STATUS" == "null" ]]; then
echo "Error: Invalid response recieved from Bitrise API"
echo "Response: $RESPONSE"
exit 1
fi
echo "Current Bitrise Build Status: $STATUS"
if [[ "$STATUS" == "success" ]]; then
echo "Bitrise Build Succeeded!"
exit 0
elif [[ "$STATUS" == "failed" ]]; then
echo "Bitrise Build Failed!"
exit 1
fi
sleep 30
done
release:
name: Deploy Release (Tag Push)
if: startsWith(github.ref, 'refs/tags/')
needs: trigger-bitrise
runs-on: ubuntu-latest
steps:
- name: Call Bitrise API for Release
run: |
BITRISE_BUILD_URL="https://api.bitrise.io/v0.1/apps/${{ secrets.BITRISE_APP_SLUG }}/builds"
curl -X POST "$BITRISE_BUILD_URL" \
-H "Authorization: Token ${{ secrets.BITRISE_API_TOKEN }}" \
-H "Content-Type: application/json" \
--data '{
"hook_info": { "type": "bitrise" },
"build_params": {
"branch": "main",
"workflow_id": "release"
},
"triggered_by": "GitHub Actions"
}'