Skip to content

Commit ed3f3ce

Browse files
committed
chore: send slack notification on sample app build
1 parent 786c9be commit ed3f3ce

File tree

1 file changed

+53
-7
lines changed

1 file changed

+53
-7
lines changed

.github/workflows/build-sample-app.yml

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,15 @@ jobs:
5555
fetch-depth: 0 # Workaround for bug https://github.com/actions/checkout/issues/1471
5656

5757
# Install CLI tools, Ruby, and Ruby dependencies for Fastlane
58-
58+
59+
- name: Set IS_PRIMARY_APP
60+
run: |
61+
if [[ "${{ inputs.app_name }}" == "APN" ]]; then
62+
echo "IS_PRIMARY_APP=true" >> $GITHUB_ENV
63+
else
64+
echo "IS_PRIMARY_APP=false" >> $GITHUB_ENV
65+
fi
66+
5967
- name: Set Default Firebase Distribution Groups
6068
shell: bash
6169
env:
@@ -65,7 +73,6 @@ jobs:
6573
NEXT_BUILDS_GROUP: next
6674
PUBLIC_BUILDS_GROUP: public
6775
# Input variables
68-
IS_PRIMARY_APP: ${{ inputs.app_name == 'APN' }}
6976
CURRENT_BRANCH: ${{ github.ref }}
7077
run: |
7178
# Initialize with the default distribution group
@@ -140,10 +147,13 @@ jobs:
140147
APP_VERSION_NAME: ${{ env.APP_VERSION_NAME }}
141148
APP_VERSION_CODE: ${{ env.APP_VERSION_CODE }}
142149

150+
- name: Set Git Context Variables
151+
run: |
152+
echo "BRANCH_NAME=${{ github.head_ref || github.ref_name }}" >> $GITHUB_ENV
153+
COMMIT_HASH="${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}"
154+
echo "COMMIT_HASH=${COMMIT_HASH:0:7}" >> $GITHUB_ENV
155+
143156
- name: Setup workspace credentials in React Native environment files
144-
env:
145-
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
146-
COMMIT_HASH: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
147157
run: |
148158
# Determine the correct file extension (.js or .ts)
149159
if [ -f "env.sample.js" ]; then
@@ -162,8 +172,8 @@ jobs:
162172
sd "cdpApiKey: '.*'" "cdpApiKey: '${{ secrets[format('CUSTOMERIO_{0}_WORKSPACE_CDP_API_KEY', inputs.app_name)] }}'" "$ENV_FILE"
163173
sd "siteId: '.*'" "siteId: '${{ secrets[format('CUSTOMERIO_{0}_WORKSPACE_SITE_ID', inputs.app_name)] }}'" "$ENV_FILE"
164174
sd "workspaceName: '.*'" "workspaceName: '${{ inputs.cio-workspace-name }}'" "$ENV_FILE"
165-
sd "branchName: '.*'" "branchName: '$BRANCH_NAME'" "$ENV_FILE"
166-
sd "commitHash: '.*'" "commitHash: '${COMMIT_HASH:0:7}'" "$ENV_FILE"
175+
sd "branchName: '.*'" "branchName: '${{ env.BRANCH_NAME }}'" "$ENV_FILE"
176+
sd "commitHash: '.*'" "commitHash: '${{ env.COMMIT_HASH }}'" "$ENV_FILE"
167177
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "untagged")
168178
COMMITS_AHEAD=$(git rev-list $LAST_TAG..HEAD --count 2>/dev/null || echo "untracked")
169179
sd "commitsAheadCount: '.*'" "commitsAheadCount: '$COMMITS_AHEAD'" "$ENV_FILE"
@@ -250,3 +260,39 @@ jobs:
250260
echo "Build failed for: ${FAILED_BUILDS[*]}"
251261
exit 1
252262
fi
263+
264+
- name: Send Slack Notification for Sample App Builds (Android)
265+
if: env.IS_PRIMARY_APP == 'true'
266+
uses: customerio/mobile-ci-tools/github-actions/slack-notify-sample-app/v1
267+
with:
268+
build_status: ${{ job.status }}
269+
app_icon_emoji: ":react:"
270+
app_name: "React Native"
271+
firebase_app_id: ${{ secrets[format('SAMPLE_APPS_{0}_ANDROID_APP_ID', inputs.app_name)] }}
272+
firebase_distribution_groups: ${{ env.firebase_distribution_groups }}
273+
git_context: "${{ env.BRANCH_NAME }} (${{ env.COMMIT_HASH }})"
274+
icon_url: "https://vectorified.com/images/icon-react-native-24.png"
275+
instructions_guide_link: ${{ secrets.SAMPLE_APPS_INSTRUCTIONS_GUIDE_LINK }}
276+
platform: "android"
277+
repository_name: "React Native"
278+
sdk_name: "React Native SDK"
279+
sdk_version: ${{ env.SDK_VERSION_NAME }}
280+
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
281+
282+
- name: Send Slack Notification for Sample App Builds (iOS)
283+
if: env.IS_PRIMARY_APP == 'true'
284+
uses: customerio/mobile-ci-tools/github-actions/slack-notify-sample-app/v1
285+
with:
286+
build_status: ${{ job.status }}
287+
app_icon_emoji: ":react:"
288+
app_name: "React Native"
289+
firebase_app_id: ${{ secrets[format('SAMPLE_APPS_{0}_IOS_APP_ID', inputs.app_name)] }}
290+
firebase_distribution_groups: ${{ env.firebase_distribution_groups }}
291+
git_context: "${{ env.BRANCH_NAME }} (${{ env.COMMIT_HASH }})"
292+
icon_url: "https://vectorified.com/images/icon-react-native-24.png"
293+
instructions_guide_link: ${{ secrets.SAMPLE_APPS_INSTRUCTIONS_GUIDE_LINK }}
294+
platform: "ios"
295+
repository_name: "React Native"
296+
sdk_name: "React Native SDK"
297+
sdk_version: ${{ env.SDK_VERSION_NAME }}
298+
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}

0 commit comments

Comments
 (0)