Skip to content

Commit 3758306

Browse files
committed
chore: send slack notification on sample app build
1 parent ce526c5 commit 3758306

File tree

2 files changed

+46
-7
lines changed

2 files changed

+46
-7
lines changed

.github/workflows/reusable_build_sample_apps.yml

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ jobs:
2525
cio-workspace-name: "Mobile: Native iOS & Android"
2626
cio-cdpapikey-secret-key: "CUSTOMERIO_JAVA_WORKSPACE_CDP_API_KEY"
2727
cio-siteid-secret-key: "CUSTOMERIO_JAVA_WORKSPACE_SITE_ID"
28+
firebase-app-id-secret-key: "SAMPLE_APPS_JAVA_FIREBASE_APP_ID"
2829
- sample-app: "kotlin_compose"
2930
cio-workspace-name: "Mobile: xiOS CocoaPods FCM + Kotlin Android"
3031
cio-cdpapikey-secret-key: "CUSTOMERIO_KOTLIN_WORKSPACE_CDP_API_KEY"
3132
cio-siteid-secret-key: "CUSTOMERIO_KOTLIN_WORKSPACE_SITE_ID"
33+
firebase-app-id-secret-key: "SAMPLE_APPS_KOTLIN_FIREBASE_APP_ID"
3234

3335
name: Building app...${{ matrix.sample-app }}
3436
permissions:
@@ -39,6 +41,14 @@ jobs:
3941
with:
4042
fetch-depth: 0 # Workaround for bug https://github.com/actions/checkout/issues/1471
4143

44+
- name: Set IS_PRIMARY_APP
45+
run: |
46+
if [[ "${{ matrix.sample-app }}" == "java_layout" ]]; then
47+
echo "IS_PRIMARY_APP=true" >> $GITHUB_ENV
48+
else
49+
echo "IS_PRIMARY_APP=false" >> $GITHUB_ENV
50+
fi
51+
4252
- name: Set Default Firebase Distribution Groups
4353
shell: bash
4454
env:
@@ -48,7 +58,6 @@ jobs:
4858
NEXT_BUILDS_GROUP: next
4959
PUBLIC_BUILDS_GROUP: public
5060
# Input variables
51-
IS_PRIMARY_APP: ${{ matrix.sample-app == 'java_layout' }}
5261
CURRENT_BRANCH: ${{ github.ref }}
5362
USE_LATEST_SDK_VERSION: ${{ inputs.use_latest_sdk_version }}
5463
run: |
@@ -85,18 +94,21 @@ jobs:
8594
ruby-version: '3.0'
8695
bundler-cache: true # cache tools to make builds faster in future
8796

97+
- name: Set Git Context Variables
98+
run: |
99+
echo "BRANCH_NAME=${{ github.head_ref || github.ref_name }}" >> $GITHUB_ENV
100+
COMMIT_HASH="${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}"
101+
echo "COMMIT_HASH=${COMMIT_HASH:0:7}" >> $GITHUB_ENV
102+
88103
- name: Setup local.properties file for sample app
89-
env:
90-
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
91-
COMMIT_HASH: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
92104
run: |
93105
LOCAL_PROPS_FILE="samples/local.properties"
94106
touch "$LOCAL_PROPS_FILE"
95107
echo "cdpApiKey=${{ secrets[matrix.cio-cdpapikey-secret-key] }}" >> "$LOCAL_PROPS_FILE"
96108
echo "siteId=${{ secrets[matrix.cio-siteid-secret-key] }}" >> "$LOCAL_PROPS_FILE"
97109
echo "workspace=${{ matrix.cio-workspace-name }}" >> "$LOCAL_PROPS_FILE"
98-
echo "branchName=$BRANCH_NAME" >> "$LOCAL_PROPS_FILE"
99-
echo "commitHash=${COMMIT_HASH:0:7}" >> "$LOCAL_PROPS_FILE"
110+
echo "branchName=${{ env.BRANCH_NAME }}" >> "$LOCAL_PROPS_FILE"
111+
echo "commitHash=${{ env.COMMIT_HASH }}" >> "$LOCAL_PROPS_FILE"
100112
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "untagged")
101113
COMMITS_AHEAD=$(git rev-list $LAST_TAG..HEAD --count 2>/dev/null || echo "untracked")
102114
echo "commitsAheadCount=$COMMITS_AHEAD" >> "$LOCAL_PROPS_FILE"
@@ -139,6 +151,31 @@ jobs:
139151
ANDROID_SIGNING_STORE_PASSWORD: ${{ secrets.ANDROID_SIGNING_STORE_PASSWORD }}
140152
FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT_CREDS_B64: ${{ secrets.FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT_CREDS_B64 }}
141153

154+
- name: Determine SDK Version
155+
id: determine-sdk-version
156+
run: |
157+
sdk_version="${{ env.SDK_VERSION || steps.latest-sdk-version-step.outputs.LATEST_TAG }}"
158+
echo "Final SDK Version: $sdk_version"
159+
echo "SDK_VERSION=$sdk_version" >> $GITHUB_ENV
160+
161+
- name: Send Slack Notification for Sample App Builds
162+
if: env.IS_PRIMARY_APP == 'true'
163+
uses: customerio/mobile-ci-tools/github-actions/slack-notify-sample-app/v1
164+
with:
165+
build_status: ${{ job.status }}
166+
app_icon_emoji: ":android:"
167+
app_name: "Android Native"
168+
firebase_app_id: ${{ secrets[matrix.firebase-app-id-secret-key] }}
169+
firebase_distribution_groups: ${{ env.firebase_distribution_groups }}
170+
git_context: "${{ env.BRANCH_NAME }} (${{ env.COMMIT_HASH }})"
171+
icon_url: "https://media.pocketgamer.com/artwork/na-qulrguj/android.jpg"
172+
instructions_guide_link: ${{ secrets.SAMPLE_APPS_INSTRUCTIONS_GUIDE_LINK }}
173+
platform: "android"
174+
repository_name: "Android"
175+
sdk_name: "Android Native SDK"
176+
sdk_version: ${{ env.SDK_VERSION }}
177+
slack_webhook_url: ${{ secrets.SLACK_NOTIFY_RELEASES_WEBHOOK_URL }}
178+
142179
- name: Update sample builds PR comment with build information
143180
if: ${{ github.event_name == 'pull_request' }}
144181
uses: peter-evans/create-or-update-comment@v4

samples/fastlane/Fastfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ private_lane :build_sample_app do |options|
3232

3333
if !options.key?(:sdk_version)
3434
UI.important("Updating the SDK's source code version to non-production version. This allows the sample apps to show the SDK version at runtime for app user to better understand the version of the SDK they are running.")
35-
sh("../../../scripts/update-version.sh \"#{new_app_version}.#{new_build_number}\"")
35+
new_sdk_version = "#{new_app_version}.#{new_build_number}"
36+
sh("../../../scripts/update-version.sh \"#{new_sdk_version}\"")
37+
sh("echo 'SDK_VERSION=#{new_sdk_version}' >> $GITHUB_ENV")
3638
end
3739

3840
build_android_app(

0 commit comments

Comments
 (0)