From 44acf889e674e672e347ac092b06b49ef843ee38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alessandro=20Pezz=C3=A8?= Date: Sun, 3 May 2020 17:16:02 +0200 Subject: [PATCH] feat: deploy staging branch to staging env --- .circleci/config.yml | 12 +++++++----- Resources/scripts/updater.sh | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 76f7d8de..955007a1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -16,7 +16,7 @@ jobs: name: Run tests command: make test - generate_data_and_trigger_pullrequest_deploy: + deploy: machine: image: ubuntu-1604:201903-01 # https://circleci.com/docs/2.0/configuration-reference/#available-machine-images with Docker 18.09.3 steps: @@ -25,17 +25,19 @@ jobs: fingerprints: - "d3:5f:9d:68:ea:12:9a:42:d3:d3:e1:db:b0:6a:fc:d2" - run: - name: Generate new data, push to PokeAPI/api-data's staging branch and open a Pull Request towards PokeAPI/api-data's master branch + name: Generate new data, push to PokeAPI/api-data's staging branch, if master open a Pull Request towards PokeAPI/api-data's master branch command: bash -x Resources/scripts/updater.sh workflows: version: 2 - test-and-generate_data_and_trigger_pullrequest_deploy: + test-and-deploy: jobs: - test - - generate_data_and_trigger_pullrequest_deploy: + - deploy: requires: - test filters: branches: - only: master + only: + - master + - circleci-hook # TODO: change to staging diff --git a/Resources/scripts/updater.sh b/Resources/scripts/updater.sh index 05a8df68..0824a489 100644 --- a/Resources/scripts/updater.sh +++ b/Resources/scripts/updater.sh @@ -197,9 +197,11 @@ clone notify_engine_pr "start" run_updater check_remote_branch "$branch_name" -sleep 300 # 5 minutes, the time it takes for CircleCI's api-data script to generate the data and for CircleCI's deploy script to deploy it to the staging environment -check_remote_branch "$branch_name" -data_repo_pr_number=$(create_pr) -customize_pr "$data_repo_pr_number" -add_reviewers_to_pr "$data_repo_pr_number" +if [ "$CIRCLE_BRANCH" = 'master' ]; then + sleep 300 # 5 minutes, the time it takes for CircleCI's api-data script to generate the data and for CircleCI's deploy script to deploy it to the staging environment + check_remote_branch "$branch_name" + data_repo_pr_number=$(create_pr) + customize_pr "$data_repo_pr_number" + add_reviewers_to_pr "$data_repo_pr_number" +fi cleanexit 0 'Done'