Skip to content

Commit 9259692

Browse files
committed
chore: migrate CI configuration from CircleCI to GitHub Actions with separate deploy jobs for iOS and Android
1 parent da83811 commit 9259692

File tree

1 file changed

+149
-121
lines changed

1 file changed

+149
-121
lines changed

.github/workflows/publish-sample.yml

Lines changed: 149 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -17,130 +17,158 @@ on:
1717
type: string
1818
default: ''
1919

20+
env:
21+
CACHE_NODE_MODULES_PATH: |
22+
node_modules
23+
packages/*/node_modules
24+
sample/node_modules
25+
2026
jobs:
21-
execute:
27+
deploy-ios:
28+
name: '[iOS] Deploy'
29+
if: ${{ github.event.inputs.platform == 'iOS' || github.event.inputs.platform == 'All' }}
30+
runs-on: macos-latest
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- name: Setup Node.js
35+
uses: actions/setup-node@v4
36+
with:
37+
node-version: '18'
38+
cache: 'yarn'
39+
40+
- name: Setup Ruby
41+
uses: ruby/setup-ruby@v1
42+
env:
43+
BUNDLE_GEMFILE: ${{ github.workspace }}/sample/ios/Gemfile
44+
with:
45+
ruby-version: '3.0.6'
46+
bundler-cache: true
47+
48+
- name: Get yarn lockfile hash
49+
id: yarn-lock-hash
50+
run: echo "hash=${{ hashFiles('**/yarn.lock') }}" >> $GITHUB_OUTPUT
51+
52+
- name: Cache node_modules
53+
id: yarn-cache
54+
uses: actions/cache@v4
55+
with:
56+
path: ${{ env.CACHE_NODE_MODULES_PATH }}
57+
key: ${{ runner.os }}-yarn-${{ steps.yarn-lock-hash.outputs.hash }}
58+
restore-keys: |
59+
${{ runner.os }}-yarn-
60+
61+
- name: Install dependencies
62+
if: steps.yarn-cache.outputs.cache-hit != 'true'
63+
run: yarn install --frozen-lockfile
64+
65+
- name: Cache CocoaPods
66+
id: cocoapods-cache
67+
uses: actions/cache@v4
68+
with:
69+
path: sample/ios/Pods
70+
key: ${{ runner.os }}-pods-${{ hashFiles('sample/ios/Podfile.lock') }}
71+
restore-keys: |
72+
${{ runner.os }}-pods-
73+
74+
- name: Install CocoaPods
75+
if: steps.cocoapods-cache.outputs.cache-hit != 'true'
76+
working-directory: sample/ios
77+
run: bundle exec pod install
78+
79+
- name: Create env.ts
80+
run: echo "export const APP_ID = '${{ secrets.SENDBIRD_APP_ID }}';" >> sample/src/env.ts
81+
82+
- name: Run fastlane iOS
83+
env:
84+
APP_VERSION: ${{ github.event.inputs.version }}
85+
MATCH_PASSWORD: ${{ secrets.FASTLANE_IOS_MATCH_PASSWORD }}
86+
MATCH_GIT_URL: ${{ secrets.FASTLANE_IOS_MATCH_GIT_URL }}
87+
PILOT_USERNAME: ${{ secrets.FASTLANE_IOS_APPLE_ID }}
88+
PILOT_APPLE_ID: ${{ secrets.FASTLANE_IOS_TEAM_ID }}
89+
PILOT_DEV_PORTAL_TEAM_ID: ${{ secrets.FASTLANE_IOS_TEAM_ID }}
90+
PILOT_ITC_PROVIDER: ${{ secrets.FASTLANE_IOS_TEAM_ID }}
91+
PILOT_SKIP_WAITING_FOR_BUILD_PROCESSING: true
92+
FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD: ${{ secrets.FASTLANE_IOS_APPLE_APPLICATION_SPECIFIC_PASSWORD }}
93+
run: |
94+
if [ -n "$APP_VERSION" ]; then
95+
yarn deploy:ios version:$APP_VERSION
96+
else
97+
yarn deploy:ios
98+
fi
99+
100+
deploy-android:
101+
name: '[Android] Deploy'
102+
if: ${{ github.event.inputs.platform == 'Android' || github.event.inputs.platform == 'All' }}
22103
runs-on: ubuntu-latest
23104
steps:
24-
- name: Set BRANCH_NAME env
25-
run: echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
105+
- uses: actions/checkout@v4
106+
107+
- name: Setup Node.js
108+
uses: actions/setup-node@v4
109+
with:
110+
node-version: '18'
111+
cache: 'yarn'
112+
113+
- name: Setup Java
114+
uses: actions/setup-java@v4
115+
with:
116+
distribution: 'temurin'
117+
java-version: '17'
118+
119+
- name: Install Ninja
120+
run: sudo apt-get update && sudo apt-get install -y ninja-build
121+
122+
- name: Setup Ruby
123+
uses: ruby/setup-ruby@v1
124+
env:
125+
BUNDLE_GEMFILE: ${{ github.workspace }}/sample/android/Gemfile
126+
with:
127+
ruby-version: '2.7.6'
128+
bundler-cache: true
129+
130+
- name: Get yarn lockfile hash
131+
id: yarn-lock-hash
132+
run: echo "hash=${{ hashFiles('**/yarn.lock') }}" >> $GITHUB_OUTPUT
133+
134+
- name: Cache node_modules
135+
id: yarn-cache
136+
uses: actions/cache@v4
137+
with:
138+
path: ${{ env.CACHE_NODE_MODULES_PATH }}
139+
key: ${{ runner.os }}-yarn-${{ steps.yarn-lock-hash.outputs.hash }}
140+
restore-keys: |
141+
${{ runner.os }}-yarn-
142+
143+
- name: Install dependencies
144+
if: steps.yarn-cache.outputs.cache-hit != 'true'
145+
run: yarn install --frozen-lockfile
146+
147+
- name: Create env.ts
148+
run: echo "export const APP_ID = '${{ secrets.SENDBIRD_APP_ID }}';" >> sample/src/env.ts
149+
150+
- name: Set up trusted certificates
151+
run: |
152+
sudo apt-get update
153+
sudo apt-get install -y ca-certificates
154+
echo 'SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt' >> $GITHUB_ENV
155+
156+
- name: Create service-account.json
157+
env:
158+
FASTLANE_ANDROID_SERVICE_ACCOUNT: ${{ secrets.FASTLANE_ANDROID_SERVICE_ACCOUNT }}
159+
FASTLANE_ANDROID_APP_ID: ${{ secrets.FASTLANE_ANDROID_APP_ID }}
160+
run: |
161+
FILE_PATH="sample/android/fastlane/service-account.json"
162+
echo "$FASTLANE_ANDROID_SERVICE_ACCOUNT" | base64 --decode > $FILE_PATH
163+
echo "GOOGLE_APPLICATION_CREDENTIALS=$GITHUB_WORKSPACE/$FILE_PATH" >> $GITHUB_ENV
164+
echo "FIREBASEAPPDISTRO_APP=$FASTLANE_ANDROID_APP_ID" >> $GITHUB_ENV
26165
27-
- name: '[${{ github.event.inputs.platform }}] Deploy trigger (CircleCI REST API)'
28-
if: ${{ github.event.inputs.platform }}
166+
- name: Run fastlane Android
29167
env:
30-
CIRCLECI_PERSONAL_API_TOKEN: ${{ secrets.CIRCLECI_PERSONAL_API_TOKEN }}
31-
BRANCH_NAME: ${{ env.BRANCH_NAME }}
32-
PLATFORM: ${{ github.event.inputs.platform }}
33-
VERSION: ${{ github.event.inputs.version }}
168+
APP_VERSION: ${{ github.event.inputs.version }}
34169
run: |
35-
curl -u ${CIRCLECI_PERSONAL_API_TOKEN}: \
36-
-X POST "https://circleci.com/api/v2/project/gh/sendbird/sendbird-uikit-react-native/pipeline" \
37-
-H "Content-Type: application/json" \
38-
-d '{
39-
"branch": "'"${BRANCH_NAME}"'",
40-
"parameters": {
41-
"platform": "'"${PLATFORM}"'",
42-
"version": "'"${VERSION}"'"
43-
}
44-
}'
45-
46-
#env:
47-
# CACHE_NODE_MODULES_PATH: |
48-
# node_modules
49-
# packages/*/node_modules
50-
# sample/node_modules
51-
#
52-
#jobs:
53-
# deploy-android:
54-
# name: '[Android] Deploy'
55-
# if: ${{ github.event.inputs.platform == 'Android' || github.event.inputs.platform == 'All' }}
56-
# runs-on: ubuntu-latest
57-
# steps:
58-
# - uses: actions/checkout@v3
59-
# - uses: actions/setup-node@v1
60-
# with:
61-
# node-version: 16.x
62-
# - uses: ruby/setup-ruby@v1
63-
# env:
64-
# BUNDLE_GEMFILE: ${{ github.workspace }}/sample/android/Gemfile
65-
# with:
66-
# ruby-version: 2.7
67-
# bundler-cache: true
68-
# - name: Get lockfile hash
69-
# id: lockfile_hash
70-
# run: echo "::set-output name=hash::${{ hashFiles('**/yarn.lock') }}"
71-
# - name: Check cached node_modules
72-
# id: check_cache
73-
# uses: actions/cache@v2
74-
# with:
75-
# path: ${{ env.CACHE_NODE_MODULES_PATH }}
76-
# key: ${{ steps.lockfile_hash.outputs.hash }}
77-
# - name: Install dependencies
78-
# if: steps.check_cache.outputs.cache-hit == ''
79-
# run: yarn install --frozen-lockfile
80-
# - name: Create env.ts
81-
# run:
82-
# echo "export const APP_ID = '${{ secrets.sendbird_app_id }}';" >> sample/src/env.ts
83-
#
84-
# - name: Create service-account.json
85-
# uses: /bang9/create-env-json@v3
86-
# id: service-account
87-
# with:
88-
# file-name: './sample/android/fastlane/service-account.json'
89-
# type: 'service_account'
90-
# auth_uri: 'https://accounts.google.com/o/oauth2/auth'
91-
# token_uri: 'https://oauth2.googleapis.com/token'
92-
# auth_provider_x509_cert_url: 'https://www.googleapis.com/oauth2/v1/certs'
93-
# project_id: ${{ secrets.fastlane_android_account_project_id }}
94-
# private_key_id: ${{ secrets.fastlane_android_account_private_key_id }}
95-
# private_key: '${{ secrets.fastlane_android_account_private_key }}'
96-
# client_email: ${{ secrets.fastlane_android_account_client_email }}
97-
# client_id: ${{ secrets.fastlane_android_account_client_id }}
98-
# client_x509_cert_url: ${{ secrets.fastlane_android_account_client_x509_cert_url }}
99-
# - name: Run fastlane
100-
# env:
101-
# FIREBASEAPPDISTRO_APP: ${{ secrets.fastlane_android_app_id }}
102-
# GOOGLE_APPLICATION_CREDENTIALS: ${{ steps.service-account.outputs.full-path }}
103-
# run: yarn deploy:android
104-
#
105-
# deploy-ios:
106-
# name: '[iOS] Deploy'
107-
# if: ${{ github.event.inputs.platform != 'Android' }}
108-
# runs-on: macos-latest
109-
# steps:
110-
# - uses: actions/checkout@v3
111-
# - uses: actions/setup-node@v1
112-
# with:
113-
# node-version: 16.x
114-
# - uses: ruby/setup-ruby@v1
115-
# env:
116-
# BUNDLE_GEMFILE: ${{ github.workspace }}/sample/ios/Gemfile
117-
# with:
118-
# ruby-version: 2.7
119-
# bundler-cache: true
120-
# - name: Get lockfile hash
121-
# id: lockfile_hash
122-
# run: echo "::set-output name=hash::${{ hashFiles('**/yarn.lock') }}"
123-
# - name: Check cached node_modules
124-
# id: check_cache
125-
# uses: actions/cache@v2
126-
# with:
127-
# path: ${{ env.CACHE_NODE_MODULES_PATH }}
128-
# key: ${{ steps.lockfile_hash.outputs.hash }}
129-
# - name: Install dependencies
130-
# if: steps.check_cache.outputs.cache-hit == ''
131-
# run:
132-
# yarn install --frozen-lockfile
133-
# - name: Install pods
134-
# run: cd sample/ios && pod install
135-
# - name: Create env.ts
136-
# run:
137-
# echo "export const APP_ID = '${{ secrets.sendbird_app_id }}';" >> sample/src/env.ts
138-
# - name: Run fastlane
139-
# env:
140-
# TEAM_ID: ${{ secrets.fastlane_ios_team_id }}
141-
# MATCH_PASSWORD: ${{ secrets.fastlane_ios_match_password }}
142-
# MATCH_GIT_URL: ${{ secrets.fastlane_ios_match_git_url }}
143-
# MATCH_GIT_BASIC_AUTHORIZATION: ${{ secrets.fastlane_ios_match_git_basic_authorization }}
144-
# APPLE_ID: ${{ secrets.fastlane_ios_apple_id }}
145-
# FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD: ${{ secrets.fastlane_ios_apple_application_specific_password }}
146-
# run: yarn deploy:ios
170+
if [ -n "$APP_VERSION" ]; then
171+
yarn deploy:android version:$APP_VERSION
172+
else
173+
yarn deploy:android
174+
fi

0 commit comments

Comments
 (0)