Last active
September 15, 2019 05:34
-
-
Save hrdtbs/52b9cd634a1265ce97144770a5cda05b to your computer and use it in GitHub Desktop.
Specific Directory to Branch on CircleCI
This file contains 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
workflows: | |
version: 2 | |
hogehoge: | |
jobs: | |
- deploy: | |
filters: | |
branches: | |
only: | |
- master | |
version: 2 | |
jobs: | |
deploy: | |
docker: | |
- image: node:latest | |
steps: | |
- checkout | |
- restore_cache: | |
keys: | |
- v{{ .Environment.CIRCLE_CACHE_VERSION }}-yarn-lock-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "yarn.lock" }} | |
- v{{ .Environment.CIRCLE_CACHE_VERSION }}-yarn-lock-master-{{ .Environment.CIRCLE_JOB }}-{{ checksum "yarn.lock" }} | |
- v{{ .Environment.CIRCLE_CACHE_VERSION }}-yarn-cache-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }} | |
- v{{ .Environment.CIRCLE_CACHE_VERSION }}-yarn-cache-master-{{ .Environment.CIRCLE_JOB }} | |
- run: | |
name: Install dependencies | |
command: yarn install | |
- run: | |
name: Build | |
command: yarn build | |
- run: | |
command: chmod 777 ./scripts/deploy.sh | |
- run: | |
command: ./scripts/deploy.sh | |
- save_cache: | |
key: v{{ .Environment.CIRCLE_CACHE_VERSION }}-yarn-lock-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "yarn.lock" }} | |
paths: | |
- node_modules | |
- save_cache: | |
key: v{{ .Environment.CIRCLE_CACHE_VERSION }}-yarn-lock-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "yarn.lock" }} | |
paths: | |
- ~/.cache/yarn |
This file contains 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
#!/bin/sh | |
set -e | |
pwd | |
remote=$(git config remote.origin.url) | |
mkdir BRANCH_NAME | |
cd BRANCH_NAME | |
git config --global user.email example@gmail.com > /dev/null 2>&1 | |
git config --global user.name USER_NAME > /dev/null 2>&1 | |
git init | |
git remote add --fetch origin "$remote" | |
if git rev-parse --verify origin/BRANCH_NAME > /dev/null 2>&1 | |
then | |
git checkout BRANCH_NAME | |
git rm -rf . | |
else | |
git checkout --orphan BRANCH_NAME | |
fi | |
cp -a ../BUILD_DIRECTORY/. . | |
git add -A | |
git commit --allow-empty -m "chore(*): release to BRANCH_NAME [ci skip]" | |
git push --force --quiet origin BRANCH_NAME | |
cd .. | |
rm -rf BRANCH_NAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment