Select deploy target, based on branch name:

```
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -17,7 +17,12 @@ jobs:
       - run:
           name: "Run Hugo"
           working_directory: /root/project/
-          command: hugo -e staging -v -s /root/project/
+          command: |
+            if [ "${CIRCLE_BRANCH}" == "master" ]; then
+              hugo -e staging -v -s /root/project/
+            else
+              hugo -e production -v -s /root/project/
+            fi

       - run:
           name: Change Amazon Links
@@ -44,7 +49,12 @@ jobs:
             ssh-keyscan -p ${SSHPORT} ${HOST_NAME} >> ~/.ssh/known_hosts

       - run:
-          name: Deploy
+          name: Deploy (Not Master)
           command: |
-            ssh -p ${SSHPORT} ${USER_NAME}@${HOST_NAME} "rm -rf /var/www/test/*"
-            rsync -e "ssh -p ${SSHPORT}" --omit-dir-times -rltvz --delete public/ ${USER_NAME}@${HOST_NAME}:/var/www/test
+            if [ "${CIRCLE_BRANCH}" != "master" ]; then
+              ssh -p ${SSHPORT} ${USER_NAME}@${HOST_NAME} "rm -rf /var/www/test/*"
+              rsync -e "ssh -p ${SSHPORT}" --omit-dir-times -rltvz --delete public/ ${USER_NAME}@${HOST_NAME}:/var/www/test
+            else
+              ssh -p ${SSHPORT} ${USER_NAME}@${HOST_NAME} "rm -rf /var/www/blog/*"
+              rsync -e "ssh -p ${SSHPORT}" --omit-dir-times -rltvz --delete public/ ${USER_NAME}@${HOST_NAME}:/var/www/blog
+            fi
```
This commit is contained in:
Kazuhiro MUSASHI 2019-05-04 22:01:41 +08:00
parent 6abf67e828
commit aca5778d06
1 changed files with 14 additions and 4 deletions

View File

@ -17,7 +17,12 @@ jobs:
- run: - run:
name: "Run Hugo" name: "Run Hugo"
working_directory: /root/project/ working_directory: /root/project/
command: hugo -e staging -v -s /root/project/ command: |
if [ "${CIRCLE_BRANCH}" == "master" ]; then
hugo -e staging -v -s /root/project/
else
hugo -e production -v -s /root/project/
fi
- run: - run:
name: Change Amazon Links name: Change Amazon Links
@ -44,7 +49,12 @@ jobs:
ssh-keyscan -p ${SSHPORT} ${HOST_NAME} >> ~/.ssh/known_hosts ssh-keyscan -p ${SSHPORT} ${HOST_NAME} >> ~/.ssh/known_hosts
- run: - run:
name: Deploy name: Deploy (Not Master)
command: | command: |
ssh -p ${SSHPORT} ${USER_NAME}@${HOST_NAME} "rm -rf /var/www/test/*" if [ "${CIRCLE_BRANCH}" != "master" ]; then
rsync -e "ssh -p ${SSHPORT}" --omit-dir-times -rltvz --delete public/ ${USER_NAME}@${HOST_NAME}:/var/www/test ssh -p ${SSHPORT} ${USER_NAME}@${HOST_NAME} "rm -rf /var/www/test/*"
rsync -e "ssh -p ${SSHPORT}" --omit-dir-times -rltvz --delete public/ ${USER_NAME}@${HOST_NAME}:/var/www/test
else
ssh -p ${SSHPORT} ${USER_NAME}@${HOST_NAME} "rm -rf /var/www/blog/*"
rsync -e "ssh -p ${SSHPORT}" --omit-dir-times -rltvz --delete public/ ${USER_NAME}@${HOST_NAME}:/var/www/blog
fi