@@ -33,12 +33,14 @@ jobs:
3333 with :
3434 fetch-depth : 0 # Workaround for bug https://github.com/actions/checkout/issues/1471
3535
36- - name : Get latest SDK version
37- if : ${{ inputs.use_latest_sdk_version == true }}
38- id : latest-sdk-version-step
36+ - name : Capture Git Context
37+ shell : bash
38+ id : git-context
3939 run : |
40- latest_tag=$(git describe --tags --abbrev=0)
41- echo "LATEST_TAG=$latest_tag" >> "$GITHUB_OUTPUT"
40+ echo "BRANCH_NAME=${{ github.head_ref || github.ref_name }}" >> $GITHUB_ENV
41+ COMMIT_HASH="${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}"
42+ echo "COMMIT_HASH=${COMMIT_HASH:0:7}" >> $GITHUB_ENV
43+ echo "LATEST_TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
4244
4345 - name : Set Default Firebase Distribution Groups
4446 shell : bash
5052 PUBLIC_BUILDS_GROUP : public
5153 # Input variables
5254 CURRENT_BRANCH : ${{ github.ref }}
55+ USE_LATEST_SDK_VERSION : ${{ inputs.use_latest_sdk_version }}
5356 run : |
5457 # Initialize with the default distribution group
5558 distribution_groups=("$ALL_BUILDS_GROUP")
@@ -100,30 +103,33 @@ jobs:
100103 with :
101104 subdirectory : apps/${{ matrix.sample-app.name }}
102105 lane : " update_flutter_android_app_version"
103- options : ${{ inputs.use_latest_sdk_version == true && format('{{"version_name":"{0}"}}', steps.latest-sdk-version-step.outputs .LATEST_TAG) || '' }}
106+ options : ${{ inputs.use_latest_sdk_version == true && format('{{"version_name":"{0}"}}', env .LATEST_TAG) || '' }}
104107 env :
105108 SDK_VERSION_NAME : ${{ env.SDK_VERSION_NAME }}
106109 APP_VERSION_NAME : ${{ env.APP_VERSION_NAME }}
107110 APP_VERSION_CODE : ${{ env.APP_VERSION_CODE }}
108111
112+ - name : Set Git Context Variables
113+ run : |
114+ echo "BRANCH_NAME=${{ github.head_ref || github.ref_name }}" >> $GITHUB_ENV
115+ COMMIT_HASH="${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}"
116+ echo "COMMIT_HASH=${COMMIT_HASH:0:7}" >> $GITHUB_ENV
117+
109118 - name : Setup workspace credentials in flutter environment files
110- env :
111- BRANCH_NAME : ${{ github.head_ref || github.ref_name }}
112- COMMIT_HASH : ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
113119 run : |
114120 ENV_FILE=".env"
115121 touch "$ENV_FILE"
116122 echo "BUILD_TIMESTAMP=$(date +%s)" >> "$ENV_FILE"
117123 echo "CDP_API_KEY=${{ secrets[format('CUSTOMERIO_{0}_WORKSPACE_CDP_API_KEY', matrix.sample-app.name)] }}" >> "$ENV_FILE"
118124 echo "SITE_ID=${{ secrets[format('CUSTOMERIO_{0}_WORKSPACE_SITE_ID', matrix.sample-app.name)] }}" >> "$ENV_FILE"
119125 echo "WORKSPACE_NAME=${{ matrix.sample-app.cio-workspace-name }}" >> "$ENV_FILE"
120- echo "BRANCH_NAME=$BRANCH_NAME" >> "$ENV_FILE"
121- echo "COMMIT_HASH=${COMMIT_HASH:0:7 }" >> "$ENV_FILE"
122- LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "untagged")
126+ echo "BRANCH_NAME=${{ env. BRANCH_NAME }} " >> "$ENV_FILE"
127+ echo "COMMIT_HASH=${{ env. COMMIT_HASH } }" >> "$ENV_FILE"
128+ LAST_TAG="${{ env.LATEST_TAG :- "untagged" }}"
123129 COMMITS_AHEAD=$(git rev-list $LAST_TAG..HEAD --count 2>/dev/null || echo "untracked")
124130 echo "COMMITS_AHEAD_COUNT=$COMMITS_AHEAD" >> "$ENV_FILE"
125131 if [ "${{ inputs.use_latest_sdk_version }}" == "true" ]; then
126- echo "SDK_VERSION=${{ steps.latest-sdk-version-step.outputs .LATEST_TAG }}" >> "$ENV_FILE"
132+ echo "SDK_VERSION=${{ env .LATEST_TAG }}" >> "$ENV_FILE"
127133 fi
128134
129135 # Make sure to fetch dependencies only after updating the version numbers and workspace credentials
@@ -154,6 +160,23 @@ jobs:
154160 FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT_CREDS_B64 : ${{ secrets.FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT_CREDS_B64 }}
155161 continue-on-error : true # continue to build iOS app even if Android build fails
156162
163+ - name : Send Slack Notification for Sample App Builds (Android)
164+ if : always()
165+ uses : customerio/mobile-ci-tools/github-actions/slack-notify-sample-app/v1
166+ with :
167+ build_status : ${{ steps.android_build.outcome }}
168+ app_icon_emoji : " :flutter:"
169+ app_name : " Flutter"
170+ firebase_app_id : ${{ secrets[format('SAMPLE_APPS_{0}_FIREBASE_APP_ID_ANDROID', matrix.sample-app.name)] }}
171+ firebase_distribution_groups : ${{ env.firebase_distribution_groups }}
172+ git_context : " ${{ env.BRANCH_NAME }} (${{ env.COMMIT_HASH }})"
173+ icon_url : " https://img.icons8.com/color/512/flutter.png"
174+ instructions_guide_link : ${{ secrets.SAMPLE_APPS_INSTRUCTIONS_GUIDE_LINK }}
175+ platform : " android"
176+ sdk_name : " Flutter SDK"
177+ sdk_version : ${{ env.SDK_VERSION_NAME }}
178+ slack_webhook_url : ${{ secrets.SLACK_WEBHOOK_URL }}
179+
157180 build-ios-sample-app :
158181 strategy :
159182 fail-fast : false # if one sample app fails to build, let the other sample apps continue to build and not cancel them.
@@ -177,12 +200,14 @@ jobs:
177200 with :
178201 fetch-depth : 0 # Workaround for bug https://github.com/actions/checkout/issues/1471
179202
180- - name : Get latest SDK version
181- if : ${{ inputs.use_latest_sdk_version == true }}
182- id : latest-sdk-version-step
203+ - name : Capture Git Context
204+ shell : bash
205+ id : git-context
183206 run : |
184- latest_tag=$(git describe --tags --abbrev=0)
185- echo "LATEST_TAG=$latest_tag" >> "$GITHUB_OUTPUT"
207+ echo "BRANCH_NAME=${{ github.head_ref || github.ref_name }}" >> $GITHUB_ENV
208+ COMMIT_HASH="${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}"
209+ echo "COMMIT_HASH=${COMMIT_HASH:0:7}" >> $GITHUB_ENV
210+ echo "LATEST_TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
186211
187212 - name : Set Default Firebase Distribution Groups
188213 shell : bash
@@ -194,6 +219,7 @@ jobs:
194219 PUBLIC_BUILDS_GROUP : public
195220 # Input variables
196221 CURRENT_BRANCH : ${{ github.ref }}
222+ USE_LATEST_SDK_VERSION : ${{ inputs.use_latest_sdk_version }}
197223 run : |
198224 # Initialize with the default distribution group
199225 distribution_groups=("$ALL_BUILDS_GROUP")
@@ -245,30 +271,33 @@ jobs:
245271 with :
246272 subdirectory : apps/${{ matrix.sample-app.name }}
247273 lane : " update_flutter_ios_app_version"
248- options : ${{ inputs.use_latest_sdk_version == true && format('{{"version_name":"{0}"}}', steps.latest-sdk-version-step.outputs .LATEST_TAG) || '' }}
274+ options : ${{ inputs.use_latest_sdk_version == true && format('{{"version_name":"{0}"}}', env .LATEST_TAG) || '' }}
249275 env :
250276 SDK_VERSION_NAME : ${{ env.SDK_VERSION_NAME }}
251277 APP_VERSION_NAME : ${{ env.APP_VERSION_NAME }}
252278 APP_VERSION_CODE : ${{ env.APP_VERSION_CODE }}
253279
280+ - name : Set Git Context Variables
281+ run : |
282+ echo "BRANCH_NAME=${{ github.head_ref || github.ref_name }}" >> $GITHUB_ENV
283+ COMMIT_HASH="${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}"
284+ echo "COMMIT_HASH=${COMMIT_HASH:0:7}" >> $GITHUB_ENV
285+
254286 - name : Setup workspace credentials in flutter environment files
255- env :
256- BRANCH_NAME : ${{ github.head_ref || github.ref_name }}
257- COMMIT_HASH : ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
258287 run : |
259288 ENV_FILE=".env"
260289 touch "$ENV_FILE"
261290 echo "BUILD_TIMESTAMP=$(date +%s)" >> "$ENV_FILE"
262291 echo "CDP_API_KEY=${{ secrets[format('CUSTOMERIO_{0}_WORKSPACE_CDP_API_KEY', matrix.sample-app.name)] }}" >> "$ENV_FILE"
263292 echo "SITE_ID=${{ secrets[format('CUSTOMERIO_{0}_WORKSPACE_SITE_ID', matrix.sample-app.name)] }}" >> "$ENV_FILE"
264293 echo "WORKSPACE_NAME=${{ matrix.sample-app.cio-workspace-name }}" >> "$ENV_FILE"
265- echo "BRANCH_NAME=$BRANCH_NAME" >> "$ENV_FILE"
266- echo "COMMIT_HASH=${COMMIT_HASH:0:7 }" >> "$ENV_FILE"
267- LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "untagged")
294+ echo "BRANCH_NAME=${{ env. BRANCH_NAME }} " >> "$ENV_FILE"
295+ echo "COMMIT_HASH=${{ env. COMMIT_HASH } }" >> "$ENV_FILE"
296+ LAST_TAG="${{ env.LATEST_TAG :- "untagged" }}"
268297 COMMITS_AHEAD=$(git rev-list $LAST_TAG..HEAD --count 2>/dev/null || echo "untracked")
269298 echo "COMMITS_AHEAD_COUNT=$COMMITS_AHEAD" >> "$ENV_FILE"
270299 if [ "${{ inputs.use_latest_sdk_version }}" == "true" ]; then
271- echo "SDK_VERSION=${{ steps.latest-sdk-version-step.outputs .LATEST_TAG }}" >> "$ENV_FILE"
300+ echo "SDK_VERSION=${{ env .LATEST_TAG }}" >> "$ENV_FILE"
272301 fi
273302
274303 - name : Setup workspace credentials in iOS environment files
@@ -315,4 +344,21 @@ jobs:
315344 options : ' {"distribution_groups": "${{ env.firebase_distribution_groups }}"}'
316345 env :
317346 GOOGLE_CLOUD_MATCH_READONLY_SERVICE_ACCOUNT_B64 : ${{ secrets.GOOGLE_CLOUD_MATCH_READONLY_SERVICE_ACCOUNT_B64 }}
318- FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT_CREDS_B64 : ${{ secrets.FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT_CREDS_B64 }}
347+ FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT_CREDS_B64 : ${{ secrets.FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT_CREDS_B64 }}
348+
349+ - name : Send Slack Notification for Sample App Builds (iOS)
350+ if : always()
351+ uses : customerio/mobile-ci-tools/github-actions/slack-notify-sample-app/v1
352+ with :
353+ build_status : ${{ steps.ios_build.outcome }}
354+ app_icon_emoji : " :flutter:"
355+ app_name : " Flutter"
356+ firebase_app_id : ${{ secrets[format('SAMPLE_APPS_{0}_FIREBASE_APP_ID_IOS', matrix.sample-app.name)] }}
357+ firebase_distribution_groups : ${{ env.firebase_distribution_groups }}
358+ git_context : " ${{ env.BRANCH_NAME }} (${{ env.COMMIT_HASH }})"
359+ icon_url : " https://img.icons8.com/color/512/flutter.png"
360+ instructions_guide_link : ${{ secrets.SAMPLE_APPS_INSTRUCTIONS_GUIDE_LINK }}
361+ platform : " ios"
362+ sdk_name : " Flutter SDK"
363+ sdk_version : ${{ env.SDK_VERSION_NAME }}
364+ slack_webhook_url : ${{ secrets.SLACK_WEBHOOK_URL }}
0 commit comments