Created
November 22, 2018 09:19
-
-
Save watanabeyu/09c6e5bfdc1c3d16ada0f157df7808fa to your computer and use it in GitHub Desktop.
if submitted pr, comment expo qr.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: 2 | |
references: | |
container_config: &container_config | |
docker: | |
- image: circleci/node:latest | |
environment: | |
EXPO_ACCOUNT: "expo_account_name" | |
EXPO_PASSWORD: "expo_account_password" | |
APP_SLUG: "expo_app_slug" | |
GITHUB_TOKEN: "git_bot_access_token" | |
working_directory: ~/repo | |
install_expo_cli: &install_expo_cli | |
run: | |
name: install-expo-cli | |
command: sudo npm install -g expo-cli | |
login_expo_cli: &login_expo_cli | |
run: | |
name: login-expo | |
command: expo login -u $EXPO_ACCOUNT -p $EXPO_PASSWORD --non-interactive | |
jobs: | |
# npm install and test | |
code_check: | |
<<: *container_config | |
steps: | |
- checkout | |
# npm setting | |
- restore_cache: | |
keys: dependency-cache-{{ checksum "package.json" }} | |
- run: | |
name: install-npm-wee | |
command: npm install | |
- save_cache: | |
key: dependency-cache-{{ checksum "package.json" }} | |
paths: | |
- node_modules | |
# workspace | |
- persist_to_workspace: | |
root: . | |
paths: | |
- . | |
# test | |
# - run: | |
# name: test | |
# command: npm run test | |
# publish feature | |
feature_build: | |
<<: *container_config | |
steps: | |
- checkout | |
# workspace | |
- attach_workspace: | |
at: . | |
# expo | |
- *install_expo_cli | |
- *login_expo_cli | |
# publish | |
- run: | |
name: publish feature and comment | |
command: ./scripts/expo_qr.sh | |
# build development | |
development_build: | |
<<: *container_config | |
steps: | |
- checkout | |
# workspace | |
- attach_workspace: | |
at: . | |
# expo | |
- *install_expo_cli | |
- *login_expo_cli | |
# publish | |
- run: | |
name: development build | |
command: npm run publish:development | |
# build production | |
production_build: | |
<<: *container_config | |
steps: | |
- checkout | |
# workspace | |
- attach_workspace: | |
at: . | |
# expo | |
- *install_expo_cli | |
- *login_expo_cli | |
# build | |
- run: | |
name: production build | |
command: npm run publish:production | |
# fastlane | |
#- run: | |
# name: production fastlane | |
# command: npm run fastlane:ios | |
workflows: | |
version: 2 | |
build_and_test: | |
jobs: | |
- code_check | |
- feature_build: | |
requires: | |
- code_check | |
filters: | |
branches: | |
ignore: | |
- develop | |
- master | |
- development_build: | |
requires: | |
- code_check | |
filters: | |
branches: | |
only: | |
- develop | |
- production_build: | |
requires: | |
- code_check | |
filters: | |
branches: | |
only: | |
- master |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -eu | |
if [ "$CIRCLE_PULL_REQUEST" == false ] || [ -z "$CIRCLE_PULL_REQUEST" ]; then | |
echo 'not pull request.' | |
exit 0 | |
fi | |
if [[ $CIRCLE_PULL_REQUEST =~ ([0-9]*)$ ]]; then | |
PR_NUMBER=${BASH_REMATCH[1]} | |
else | |
echo 'cannot get pull request number. maybe bug.' | |
exit 1 | |
fi | |
eval "ln -fs ./app.development.json app.json" | |
eval "expo publish --release-channel $CIRCLE_SHA1" | |
EXP_URL="https://exp.host/@$EXPO_ACCOUNT/$APP_SLUG?release-channel=$CIRCLE_SHA1" | |
COMMENT_BODY="$EXP_URL\n\n" | |
POST_BODY="{\"body\": \"$COMMENT_BODY\"}" | |
curl -XPOST \ | |
-H "Authorization: token $GITHUB_TOKEN" \ | |
-H "Content-Type: application/json" \ | |
-d "$POST_BODY" \ | |
https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/issues/$PR_NUMBER/comments |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment