Skip to content

Commit

Permalink
CM-0/feat: setup build
Browse files Browse the repository at this point in the history
  • Loading branch information
mainguyen-liberty committed Jul 3, 2024
1 parent 20a6e8c commit 48a8132
Showing 1 changed file with 29 additions and 233 deletions.
262 changes: 29 additions & 233 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,35 @@
name: Bubble Princess
name: Apple Pen

on:
repository_dispatch:
types:
- ppap
- dev-*
- stg-*
- pro-*

env:
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
TELEGRAM_GROUP_ID: ${{ secrets.TELEGRAM_GROUP_ID }}
TELEGRAM_TOPIC_ID: ${{ secrets.TELEGRAM_TOPIC_ID }}
# ================= NEW FLOW
NO_FLIPPER: "1"
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
# ENVIRONMENT OF REPO
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
REF_NAME: ${{ github.event.client_payload.ref_name }}
TRIGGERING_ACTOR: ${{ github.event.client_payload.triggering_actor }}
MAIN_REPOSITORY: ${{ secrets.CUCU_REPOSITORY }}
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
PRO_API_KEY_JSON: ${{secrets.PRO_API_KEY_JSON}}
API_KEY_JSON: ${{secrets.API_KEY_JSON}}
FIREBASE_CLI_TOKEN: ${{secrets.DEV_FIREBASE_CLI_TOKEN}}
SSH_PRIVATE_KEY_SDK_CORE_CLIENT: ${{secrets.SSH_PRIVATE_KEY_SDK_CORE_CLIENT}}
DYNAMIC_CONSTANTS_TS_PROD_BASE64: ${{secrets.DYNAMIC_CONSTANTS_TS_PROD_BASE64}}
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
TELEGRAM_GROUP_ID: ${{ vars.TELEGRAM_GROUP_ID }}
TELEGRAM_TOPIC_ID: ${{ vars.TELEGRAM_TOPIC_ID }}
API_KEY_JSON: ${{ secrets.API_KEY_JSON }}
PRO_API_KEY_JSON: ${{ secrets.PRO_API_KEY_JSON }}
PRO_PLAY_STORE_KEY_JSON: ${{ secrets.PRO_PLAY_STORE_KEY_JSON }}
RELEASE_KEYSTORE_BASE64: ${{ secrets.RELEASE_KEYSTORE_BASE64 }}
DYNAMIC_CONSTANTS_TS_PROD_BASE64: ${{ secrets.CUCU_DYNAMIC_CONSTANTS_TS_PROD_BASE64 }}
PRO_GOOGLE_SERVICES_JSON: ${{ secrets.CUCU_PRO_GOOGLE_SERVICES_JSON }}
PRO_GOOGLESERVICE_INFO_PLIST: ${{ secrets.CUCU_PRO_GOOGLESERVICE_INFO_PLIST }}

jobs:
init:
name: Init
runs-on: macos-14
outputs:
matrix-info: ${{ steps.set-matrix.outputs.value }}
matrix: ${{ steps.set-matrix.outputs.value }}
message-information: ${{ steps.get-message-information.outputs.value }}
env: ${{ steps.set-env.outputs.value }}
steps:
Expand All @@ -46,7 +44,7 @@ jobs:
id: set-matrix
run: |
MATRIX="[{\"format\":\"IPA\",\"name\":\"macos-14\",\"platform\":\"IOS\"},{\"format\":\"APK\",\"name\":\"ubuntu-22.04\",\"platform\":\"ANDROID\"}]"
if [[ "$REF_NAME" =~ "pro" ]]; then
if [[ "$REF_NAME" =~ "prd" ]]; then
MATRIX="[{\"format\":\"IPA\",\"name\":\"macos-14\",\"platform\":\"IOS\"},{\"format\":\"APK\",\"name\":\"ubuntu-22.04\",\"platform\":\"ANDROID\"},{\"format\":\"AAB\",\"name\":\"ubuntu-22.04\",\"platform\":\"ANDROID\"}]"
fi
echo "value=$MATRIX" >> $GITHUB_OUTPUT
Expand All @@ -55,8 +53,8 @@ jobs:
id: set-env
run: |
ENV='dev'
if [[ "$REF_NAME" =~ "pro" ]]; then
ENV='prod'
if [[ "$REF_NAME" =~ "prd" ]]; then
ENV='prd'
elif [[ "$REF_NAME" =~ "stg" ]]; then
ENV='stg'
fi
Expand All @@ -65,7 +63,7 @@ jobs:
- name: Generate message
id: get-message-information
run: |
source scripts/func/config.sh
source .github/scripts/utils.sh
echo "value=$(get_message_information)" >> "$GITHUB_OUTPUT"
timeout-minutes: 1

Expand All @@ -74,14 +72,14 @@ jobs:
echo "tag-source: $REF_NAME"
echo "matrix: ${{ steps.set-matrix.outputs.value }}"
echo "message-information: ${{ steps.get-message-information.outputs.value }}"
# echo "env: ${{ steps.set-env.outputs.value }}"
echo "env: ${{ steps.set-env.outputs.value }}"
# - name: Send telegram message
# if: vars.IS_SILENT != 'true'
# uses: PacificPromise/macos-telegram-action@main
# with:
# type: topic
# message: "🎬 - Start build: ${{ steps.get-message-information.outputs.value }}"
- name: Send telegram message
if: vars.IS_SILENT != 'true'
uses: PacificPromise/macos-telegram-action@main
with:
type: topic
message: "🎬 - Start build: ${{ steps.get-message-information.outputs.value }}"

prepare:
name: Prepare ${{ matrix.platform }}
Expand All @@ -104,211 +102,9 @@ jobs:
token: ${{ secrets.GH_PAT }}
ref: ${{ github.event.client_payload.ref_name}}

- name: Log values
- name: Log value
run: |
echo "tag-source: $REF_NAME"
echo "matrix: ${{ needs.init.outputs.matrix-info }}"
echo "env: ${{ needs.init.outputs.env }}"
echo "message-information: ${{ needs.init.outputs.message-information }}"
echo "matrix: ${{ needs.init.outputs.matrix-info }}"
- name: Setup Node v18
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"

- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ matrix.platform }}-cache-node-modules-${{ hashFiles('yarn.lock') }}
lookup-only: true

- name: Unlock ssh agent
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY_SDK_CORE_CLIENT }}

- name: Run yarn install
if: steps.cache-node-modules.outputs.cache-hit != 'true'
uses: borales/actions-yarn@v5
with:
cmd: install --network-concurrency 1

- name: Send telegram message failure
if: ${{ failure() && vars.IS_SILENT != 'true' }}
uses: PacificPromise/macos-telegram-action@main
with:
type: topic
message: "💥 - Failure ${{ matrix.platform }}: ${{ needs.init.outputs.message-information }}"

deploy:
name: Deployment ${{ matrix.format }}
continue-on-error: true
strategy:
fail-fast: true
matrix:
include:
- ${{fromJson(needs.init.outputs.matrix)}}
runs-on: ${{ matrix.name }}
needs: [init, prepare]
timeout-minutes: 60
steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: ${{ env.MAIN_REPOSITORY }}
token: ${{ secrets.GH_PAT }}
ref: ${{ github.event.client_payload.ref_name}}

# NOTE: setup environment
- name: Setup ruby 3.0.0
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.0.0"
bundler-cache: true

# - name: Setup Node v18
# uses: actions/setup-node@v4
# with:
# node-version-file: ".nvmrc"

# - name: Setup JDK 11
# if: matrix.platform == 'ANDROID'
# uses: actions/setup-java@v2
# with:
# java-version: 11
# distribution: "temurin"

# - name: Setup Android SDK
# if: matrix.platform == 'ANDROID'
# uses: android-actions/setup-android@v2

# - name: Setup Android NDK
# uses: nttld/setup-ndk@v1
# if: matrix.platform == 'ANDROID'
# with:
# ndk-version: r26c

# - name: Setup cocoapods
# if: matrix.platform == 'IOS'
# uses: maxim-lobanov/setup-cocoapods@v1
# with:
# version: 1.14.3

# - name: Select Xcode
# if: matrix.platform == 'IOS'
# uses: maxim-lobanov/setup-xcode@v1
# with:
# xcode-version: "15.3"

# # NOTE: install libs
# - name: Cache node_modules
# id: cache-node-modules
# uses: actions/cache@v4
# with:
# path: node_modules
# key: ${{ matrix.platform }}-cache-node-modules-${{ hashFiles('yarn.lock') }}

# - name: Remove code-push
# if: needs.init.outputs.env == 'prod'
# shell: bash
# run: bash scripts/remove_code_push_config.sh && yarn remove react-native-code-push && cd ..

# - name: Cache Pods
# if: matrix.platform == 'IOS'
# id: cache-pods
# uses: actions/cache@v4
# with:
# path: |
# ios/Pods
# ios/Podfile.lock
# key: cache-pods-${{ hashFiles('yarn.lock') }}

# - name: Pod install
# if: ${{ (matrix.platform == 'IOS') && (steps.cache-pods.outputs.cache-hit != 'true') }}
# working-directory: ios
# run: pod install

# - name: Cache Xcode build
# uses: irgaly/xcode-cache@v1
# if: matrix.platform == 'IOS'
# with:
# key: xcode-cache-deriveddata-${{ needs.init.outputs.env }}-${{ hashFiles('yarn.lock') }}
# restore-keys: xcode-cache-deriveddata-${{ needs.init.outputs.env }}-

# # NOTE: load environment and file
# - name: Load secret files
# run: bash scripts/load_secret_file.sh

# - name: Change version and build number
# run: bash scripts/change_version_and_build_number.sh

# - name: Config environment
# run: bash scripts/load_build_configure_${{ needs.init.outputs.env }}.sh

# - name: Generate launcher icon
# uses: borales/actions-yarn@v5
# with:
# cmd: appicon:create

# - name: Install certificate and provision
# if: matrix.platform == 'IOS'
# run: bash scripts/install_cert_and_provision.sh

# - name: Link Node (/usr/local/bin/node)
# if: matrix.platform == 'IOS'
# run: ln -s $(command -v node) /usr/local/bin/node

# # NOTE: start build
# - name: Build IPA
# if: matrix.format == 'IPA'
# uses: maierj/[email protected]
# with:
# lane: "ios build_ipa_${{ needs.init.outputs.env }}"

# - name: Build APK
# if: matrix.format == 'APK'
# uses: maierj/[email protected]
# with:
# lane: "android build_apk_${{ needs.init.outputs.env }}"

# - name: Build AAB
# if: matrix.format == 'AAB'
# uses: maierj/[email protected]
# with:
# lane: "android build_aab_prod"

# # NOTE: deploy
# - name: Deploy ipa
# if: matrix.format == 'IPA'
# uses: maierj/[email protected]
# with:
# lane: ios deploy_ipa_${{ needs.init.outputs.env }}

# - name: Deploy APK to firebase
# if: matrix.format == 'APK'
# uses: maierj/[email protected]
# with:
# lane: android deploy_apk_${{ needs.init.outputs.env }}

# # - name: Deploy AAB to playstore
# # if: matrix.format == 'AAB'
# # uses: maierj/[email protected]
# # with:
# # lane: android upload_to_open_testing_play_store

# - name: Send telegram message
# if: vars.IS_SILENT != 'true'
# uses: PacificPromise/macos-telegram-action@main
# with:
# type: topic
# message: "✅ - Success ${{ matrix.format }}: ${{ needs.init.outputs.message-information }}"

# - name: Send telegram message failure
# if: ${{ failure() && vars.IS_SILENT != 'true' }}
# uses: PacificPromise/macos-telegram-action@main
# with:
# type: topic
# message: "💥 - Failure ${{ matrix.format }}: ${{ needs.init.outputs.message-information }}"
echo "matrix: ${{ needs.init.outputs.matrix }}"
echo "message-information: ${{ needs.init.outputs.env }}"
echo "env: ${{ needs.init.outputs.message-information }}"

0 comments on commit 48a8132

Please sign in to comment.