@@ -45,186 +45,39 @@ jobs:
45
45
${{ steps.build.outputs.build-log }}
46
46
edit-mode : replace # replace the existing comment with new content since we are creating new builds
47
47
48
- build-ios-sample-apps :
48
+
49
+ build-sample-apps :
49
50
if : ${{ always() }} # do not skip running this step if update-pr-comment does not run
50
51
needs : [ update-pr-comment ] # wait for PR comment to be created saying new builds are being made.
52
+ uses : ./.github/workflows/reusable_build_sample_apps.yml
53
+ with :
54
+ use_latest_sdk_version : false
55
+ secrets : inherit
56
+
57
+ update-pr-comment-after-apps-built :
58
+ if : always() && ${{ github.event_name == 'pull_request' }}
59
+ needs : [ update-pr-comment, build-sample-apps ] # wait for PR comment to be created saying new builds are being made.
60
+ runs-on : ubuntu-latest
51
61
permissions :
52
- pull-requests : write # comment on pull request with build information
53
- strategy :
54
- fail-fast : false # if one sample app fails to build, let the other sample apps continue to build and not cancel them.
55
- matrix : # Use a matrix allowing us to build multiple apps in parallel. Just add an entry to the matrix and it will build!
56
- sample-app :
57
- # List all sample apps you want to have compiled.
58
- # List item is name of directory inside of "apps" directory for the corresponding app to compile.
59
- - name : " amiapp_flutter"
60
- cio-workspace-name : " Mobile: Flutter"
61
- defaults :
62
- run :
63
- working-directory : apps/${{ matrix.sample-app.name }}
64
- runs-on : macos-14
65
- name : Building sample app ${{ matrix.sample-app.name }}
66
- steps :
67
- - uses : actions/checkout@v4
68
-
69
- - name : Set Default Firebase Distribution Groups
70
- shell : bash
71
- env :
72
- # Distribution group constants
73
- ALL_BUILDS_GROUP : all-builds
74
- FEATURE_BUILDS_GROUP : feature-branch
75
- NEXT_BUILDS_GROUP : next
76
- PUBLIC_BUILDS_GROUP : public
77
- # Input variables
78
- CURRENT_BRANCH : ${{ github.ref }}
79
- run : |
80
- # Initialize with the default distribution group
81
- distribution_groups=("$ALL_BUILDS_GROUP")
82
-
83
- # Append distribution groups based on branch and context
84
- [[ "$CURRENT_BRANCH" == "refs/heads/feature/"* ]] && distribution_groups+=("$FEATURE_BUILDS_GROUP")
85
- [[ "$CURRENT_BRANCH" == "refs/heads/main" ]] && distribution_groups+=("$NEXT_BUILDS_GROUP")
86
- [[ "$CURRENT_BRANCH" == "refs/heads/main" ]] && distribution_groups+=("$PUBLIC_BUILDS_GROUP")
87
-
88
- # Export the groups as an environment variable
89
- echo "firebase_distribution_groups=$(IFS=','; echo "${distribution_groups[*]}")" >> $GITHUB_ENV
90
-
91
- # Install CLI tools, Ruby, and Ruby dependencies for Fastlane
92
-
93
- - name : Install CLI tools used in CI script
94
- shell : bash
95
- run : |
96
- brew install sd # used in CI script as an easier to use sed CLI. Replaces text in files.
97
- brew install xcbeautify # used by fastlane for output
98
-
99
- - name : Install Ruby
100
- uses : ruby/setup-ruby@v1
101
- with :
102
- bundler-cache : true # cache tools to make builds faster in future
103
- working-directory : apps/${{ matrix.sample-app.name }}
104
-
105
- # Update version numbers and workspace credentials before building the app
106
-
107
- - name : Generate New Version
108
- uses : maierj/fastlane-action@v3.1.0
109
- with :
110
- subdirectory : apps/${{ matrix.sample-app.name }}
111
- lane : " generate_new_version"
112
- options : ' {"branch_name":"${{ github.ref_name }}", "pull_request_number":"${{ github.event.pull_request.number }}"}'
113
-
114
- - name : Update Flutter SDK Version
115
- uses : maierj/fastlane-action@v3.1.0
116
- with :
117
- subdirectory : apps/${{ matrix.sample-app.name }}
118
- lane : " update_flutter_sdk_version"
119
- env :
120
- SDK_VERSION_NAME : ${{ env.SDK_VERSION_NAME }}
121
- APP_VERSION_NAME : ${{ env.APP_VERSION_NAME }}
122
- APP_VERSION_CODE : ${{ env.APP_VERSION_CODE }}
123
-
124
- - name : Update Sample App Version
125
- uses : maierj/fastlane-action@v3.1.0
126
- with :
127
- subdirectory : apps/${{ matrix.sample-app.name }}
128
- lane : " update_flutter_app_version"
129
- env :
130
- SDK_VERSION_NAME : ${{ env.SDK_VERSION_NAME }}
131
- APP_VERSION_NAME : ${{ env.APP_VERSION_NAME }}
132
- APP_VERSION_CODE : ${{ env.APP_VERSION_CODE }}
133
-
134
- - name : Setup workspace credentials in flutter environment files
135
- env :
136
- BRANCH_NAME : ${{ github.head_ref || github.ref_name }}
137
- COMMIT_HASH : ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
138
- run : |
139
- env_file=".env"
140
- touch "$env_file"
141
- echo "BUILD_TIMESTAMP=$(date +%s)" >> "$env_file"
142
- echo "CDP_API_KEY=${{ secrets[format('CUSTOMERIO_{0}_WORKSPACE_CDP_API_KEY', matrix.sample-app.name)] }}" >> "$env_file"
143
- echo "SITE_ID=${{ secrets[format('CUSTOMERIO_{0}_WORKSPACE_SITE_ID', matrix.sample-app.name)] }}" >> "$env_file"
144
- echo "WORKSPACE_NAME=${{ matrix.sample-app.cio-workspace-name }}" >> "$env_file"
145
- echo "BRANCH_NAME=$BRANCH_NAME" >> "$env_file"
146
- echo "COMMIT_HASH=${COMMIT_HASH:0:7}" >> "$env_file"
147
- echo "COMMITS_AHEAD_COUNT=$(git rev-list $(git describe --tags --abbrev=0)..HEAD --count)" >> "$env_file"
148
- # Add `SDK_VERSION` to env_file here if it's a public build
149
-
150
- - name : Setup workspace credentials in iOS environment files
151
- run : |
152
- cp "ios/Env.swift.example" "ios/Env.swift"
153
- sd 'cdpApiKey: String = ".*"' "cdpApiKey: String = \"${{ secrets[format('CUSTOMERIO_{0}_WORKSPACE_CDP_API_KEY', matrix.sample-app.name)] }}\"" "ios/Env.swift"
154
-
155
- # Make sure to fetch dependencies only after updating the version numbers and workspace credentials
156
-
157
- - name : Setup flutter environment and install dependencies
158
- uses : ./.github/actions/setup-flutter
159
-
160
- - name : Install flutter dependencies for sample app
161
- run : flutter pub get
162
-
163
- - name : Setup Android environment for sample app
164
- uses : customerio/customerio-android/.github/actions/setup-android@main
165
-
166
- - name : Build and upload Android app via Fastlane
167
- id : android_build
168
- uses : maierj/fastlane-action@v3.1.0
169
- with :
170
- subdirectory : apps/${{ matrix.sample-app.name }}
171
- lane : ' android build'
172
- options : ' {"distribution_groups": "${{ env.firebase_distribution_groups }}"}'
173
- env :
174
- FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT_CREDS_B64 : ${{ secrets.FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT_CREDS_B64 }}
175
- continue-on-error : true # continue to build iOS app even if Android build fails
176
-
177
- - name : Setup iOS environment for sample app
178
- uses : customerio/customerio-ios/.github/actions/setup-ios@main
179
- with :
180
- xcode-version : ${{ env.XCODE_VERSION }}
181
-
182
- - name : Cache CocoaPods downloaded dependencies for faster builds in the future
183
- uses : actions/cache@v4
184
- with :
185
- path : Pods
186
- key : ${{ runner.os }}-${{ matrix.sample-app.name }}-Pods-${{ github.ref }}
187
- restore-keys : |
188
- ${{ runner.os }}-${{ matrix.sample-app.name }}-Pods
189
-
190
- - name : pod install
191
- run : pod install --project-directory=ios
192
-
193
- - name : Build and upload iOS app via Fastlane
194
- id : ios_build
195
- uses : maierj/fastlane-action@v3.1.0
196
- with :
197
- subdirectory : apps/${{ matrix.sample-app.name }}
198
- lane : " ios build"
199
- options : ' {"distribution_groups": "${{ env.firebase_distribution_groups }}"}'
200
- env :
201
- GOOGLE_CLOUD_MATCH_READONLY_SERVICE_ACCOUNT_B64 : ${{ secrets.GOOGLE_CLOUD_MATCH_READONLY_SERVICE_ACCOUNT_B64 }}
202
- FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT_CREDS_B64 : ${{ secrets.FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT_CREDS_B64 }}
203
-
204
- - name : Check build statuses and mark failure
205
- run : |
206
- if [ "${{ steps.android_build.outcome }}" != "success" ] || [ "${{ steps.ios_build.outcome }}" != "success" ]; then
207
- echo "One or more builds failed."
208
- exit 1
209
- fi
210
-
62
+ pull-requests : write # to be able to comment on PR
63
+ steps :
211
64
- name : Update sample builds PR comment with build information
212
- if : ${{ github.event_name == 'pull_request ' }}
65
+ if : ${{ needs.build-sample-apps.result == 'success ' }}
213
66
uses : peter-evans/create-or-update-comment@v4
214
67
with :
215
68
comment-id : ${{ needs.update-pr-comment.outputs.comment-id }}
216
69
issue-number : ${{ github.event.pull_request.number }}
217
70
# the variables APP_VERSION_NAME, APP_VERSION_CODE are created when fastlane runs "build".
218
71
body : |
219
- * ${{ matrix.sample-app.name }} : `${{ env.APP_VERSION_NAME }} (${{ env.APP_VERSION_CODE }})`
72
+ * amiapp_flutter : `${{ env.APP_VERSION_NAME }} (${{ env.APP_VERSION_CODE }})`
220
73
edit-mode : append # append new line to the existing PR comment to build a list of all sample app builds.
221
74
222
75
- name : Update sample builds PR comment with build failure message
223
- if : ${{ github.event_name == 'pull_request' && failure() }}
76
+ if : ${{ needs.build-sample-apps.result == 'failure' }}
224
77
uses : peter-evans/create-or-update-comment@v4
225
78
with :
226
79
comment-id : ${{ needs.update-pr-comment.outputs.comment-id }}
227
80
issue-number : ${{ github.event.pull_request.number }}
228
81
body : |
229
- * ${{ matrix.sample-app.name }} : Build failed. See [CI job logs](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}) to determine the issue and try re-building.
82
+ * amiapp_flutter : Build failed. See [CI job logs](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}) to determine the issue and try re-building.
230
83
edit-mode : append # append new line to the existing PR comment to build a list of all sample app builds.
0 commit comments