# 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: my-org APP_NAME: my-app-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 gem install cpflow - run: name: Containerize and push image command: cpflow build-image -a ${APP_NAME} - run: name: Database tasks command: cpflow run -a ${APP_NAME} --image latest -- rails db:migrate - run: name: Deploy image command: cpflow 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 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 gem install cpflow - run: name: Provision review app if needed command: | if ! cpflow exists -a ${APP_NAME}; then cpflow setup-app -a ${APP_NAME} echo "export NEW_APP=true" >> $BASH_ENV fi - run: name: Containerize and push image command: | cpflow build-image -a ${APP_NAME} --commit ${CIRCLE_SHA1::7} - run: name: Database tasks command: | if [ -n "${NEW_APP}" ]; then cpflow run -a ${APP_NAME} --image latest -- rails db:reset else cpflow run -a ${APP_NAME} --image latest -- rails db:migrate fi - run: name: Deploy image command: cpflow 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