# Example config for staging app: # - triggers on push to master # - static app name # - no resource provisioning # - no database setup, only migration build-staging: docker: - image: cimg/ruby:3.1-node resource_class: large environment: CPLN_ORG: myorg APP_NAME: myapp-staging steps: - checkout - setup_remote_docker: docker_layer_caching: true - run: name: Install Control Plane tools command: | sudo npm install -g @controlplane/cli && cpln --version cpln profile create default --token ${CPLN_TOKEN} --org ${CPLN_ORG} --gvc ${APP_NAME} cpln image docker-login git clone https://github.com/shakacode/heroku-to-control-plane ~/heroku-to-control-plane sudo ln -s ~/heroku-to-control-plane/cpl /usr/local/bin/cpl - run: name: Containerize and push image command: cpl build-image -a ${APP_NAME} - run: name: Database tasks command: cpl run:detached rails db:migrate -a ${APP_NAME} --image latest - run: name: Deploy image command: cpl deploy-image -a ${APP_NAME} # Example config for review app: # - triggers manually if needed # - dynamic app name based on PR number # - resources provisioning for new apps # - initial database setup or migration build-review-app: docker: - image: cimg/ruby:3.1-node resource_class: large environment: CPLN_ORG: my-org-name steps: - checkout - setup_remote_docker: docker_layer_caching: true - run: name: Setup environment command: | PR_NUM=$(echo $CIRCLE_PULL_REQUEST | grep -Eo '[0-9]+$') echo "export APP_NAME=hichee-review-$PR_NUM" >> $BASH_ENV - run: name: Install Control Plane tools command: | sudo npm install -g @controlplane/cli && cpln --version cpln profile create default --token ${CPLN_TOKEN} --org ${CPLN_ORG} --gvc ${APP_NAME} cpln image docker-login git clone https://github.com/shakacode/heroku-to-control-plane ~/heroku-to-control-plane sudo ln -s ~/heroku-to-control-plane/cpl /usr/local/bin/cpl - run: name: Provision review app if needed command: | if ! cpl exist -a ${APP_NAME}; then cpl setup gvc postgres redis memcached rails sidekiq -a ${APP_NAME} echo "export NEW_APP=true" >> $BASH_ENV fi - run: name: Containerize and push image command: | cpl build-image -a ${APP_NAME} --commit ${CIRCLE_SHA1::7} - run: name: Database tasks command: | if [ -n "${NEW_APP}" ]; then cpl run:detached 'LOG_LEVEL=warn rails db:reset' -a ${APP_NAME} --image latest else cpl run:detached 'LOG_LEVEL=warn rails db:migrate' -a ${APP_NAME} --image latest fi - run: name: Deploy image command: cpl deploy-image -a ${APP_NAME} review-app: jobs: - start: filters: branches: ignore: master type: approval - build-review-app: filters: branches: ignore: master requires: - start staging: jobs: - build-staging: filters: branches: only: master