Skip to content

Instantly share code, notes, and snippets.

@shubhamkakkar
Created November 28, 2021 10:11
Show Gist options
  • Save shubhamkakkar/20cbabad168a0630118ec1655981cf12 to your computer and use it in GitHub Desktop.
Save shubhamkakkar/20cbabad168a0630118ec1655981cf12 to your computer and use it in GitHub Desktop.
React Native, git submodules and CI/CD
wversion: 2.1
node_image: &node_image
docker:
- image: node:12
android_image: &android_image
docker:
- image: reactnativecommunity/react-native-android
aliases:
- &restore-yarn-cache
name: Restore cached root node_modules
keys:
- yarn-main-cache-{{ checksum "yarn.lock" }}
- yarn-main-cache- # partial cache restore (get as much as possible dependencies from the most recent cache rather than start from zero)
- &restore-submodule-yarn-cache
name: Restore cached submodule node_modules
keys:
- yarn-main-cache-{{ checksum "yarn.lock" }}
- yarn-main-cache- # partial cache restore (get as much as possible dependencies from the most recent cache rather than start from zero)
- &save-yarn-cache
name: Save node_modules to cache
key: yarn-main-cache-{{ checksum "yarn.lock" }}
paths:
- node_modules
- &save-submodule-yarn-cache
name: Save Submodules to cache
key: submodule-cache-{{ epoch }} # cache submodule for next android varient builds Jobs
paths:
- "./submodule/submodule_name"
restore_yarn_cache: &restore_yarn_cache
restore_cache: *restore-yarn-cache
save_yarn_cache: &save_yarn_cache
save_cache: *save-yarn-cache
restore_submodule_yarn_cache: &restore_submodule_yarn_cache
restore_cache: *restore-submodule-yarn-cache
save_submodule_yarn_cache: &save_submodule_yarn_cache
save_cache: *save-submodule-yarn-cache
jobs:
node_build:
<<: *node_image
steps:
- checkout
- *restore_yarn_cache
- run: yarn prepare_submodule
- *restore_submodule_yarn_cache
- run: yarn --cwd ./submoduule/submodaule_name
- *save_submodule_yarn_cache
- run: yarn install --network-concurrency 1
- *save_yarn_cache
android_build_staging:
<<: *android_image
steps:
- checkout
- run: yarn config set script-shell /bin/bash
- run: yarn ci:create-release-key
- *restore_yarn_cache
- *restore_submodule_yarn_cache
- run: yarn build:apk "staging"
- store_artifacts:
path: staging_build/
destination: staging_build/apk-file
workflows:
build:
jobs:
- node_build:
filters:
branches:
only:
- /^staging\/v/gm
- android_build_staging:
requires:
- node_build
filters:
branches:
only: /^staging\/v/gm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment