Skip to main content

CircleCI: Skpr

Skpr provides developers with a command-line interface for scripting complex workflows.

Development teams are also able to leverage the command-line client in CI/CD workflows using our offical Docker image.

This document outlines some of the tasks that can be accomplished using this integration.

Examples in this document may not be directly suitable and may need adjusting to your project, so please keep this in mind.

Skpr Orb

The Skpr platform team maintains a CircleCI Orb which can be used to simplify your CircleCI configuration.

The examples below will showcase how this orb can be integrated into your CirlceCI workflow.

Examples

Backup an environment

You can perform a pre-deployment backup which will wait for the backup to complete before continuing.

CircleCI Configuration

version: 2.1

orbs:
skpr: skpr/skpr@1.3.2

jobs:
backup:
docker:
- image: skpr/cli:v0.18.0
steps:
- checkout
- setup_remote_docker:
version: "20.10.11"
docker_layer_caching: true
- skpr/backup:
target: dev

workflows:
backup:
jobs:
- backup:
context: skpr-cluster-name
filters:
branches:
only: [ main ]

Deploying an application

The following example demonstrates how development teams can set up a tag-based deployment workflow for their project using the Skpr Orb integration.

Workflow Outline

  • When pushing to main branch, deploy to dev environment
  • When pushing a tag, deploy to stg environment
  • Approve release via CircleCI web console, deploy to prod environment

CircleCI Configuration

version: 2.1

orbs:
skpr: skpr/skpr@1.2

commands:
skpr-pre-package:
steps:
- run:
name: Pull Base Images
command: |
docker pull skpr/php-cli:8.1-v2-latest
docker pull skpr/php-fpm:8.1-v2-latest
docker pull skpr/nginx-drupal:v2-latest

skpr-post-deploy:
parameters:
env:
type: string
steps:
- run:
name: Skpr Post-Deploy
command: skpr exec << parameters.env >> -- make deploy

workflows:
deploy:
jobs:
- skpr/deploy:
name: deploy_dev
env: dev
pre-package: [ skpr-pre-package ]
post-deploy:
- skpr-post-deploy: { env: dev }
filters:
branches:
only: [ main ]

- skpr/deploy:
name: deploy_stg
env: stg
pre-package: [ skpr-pre-package ]
post-deploy:
- skpr-post-deploy: { env: stg }
filters:
branches:
ignore: /.*/
tags:
only: /^\d+\.\d+\.\d+[0-9A-Za-z-]*$/

- approve:
type: approval
requires:
- deploy_stg
filters:
branches:
ignore: /.*/
tags:
only: /^\d+\.\d+\.\d+[0-9A-Za-z-]*$/

- skpr/deploy:
name: deploy_prod
env: prod
package: false
post-deploy:
- skpr-post-deploy: { env: prod }
requires:
- approve
filters:
branches:
ignore: /.*/
tags:
only: /^\d+\.\d+\.\d+[0-9A-Za-z-]*$/

Restoring a backup

You can perform pre and/or post deployment restore which will restore the latest available backup from a source environment to the target environment.

CircleCI Configuration

version: 2.1

orbs:
skpr: skpr/skpr@1.3.2

jobs:
backup:
docker:
- image: skpr/cli:v0.18.0
steps:
- checkout
- setup_remote_docker:
version: "20.10.11"
docker_layer_caching: true
- skpr/restore:
source: prod
target: dev

workflows:
backup:
jobs:
- backup:
context: skpr-cluster-name
filters:
branches:
only: [ main ]

Environment synchronisation

A combination of backup and restore will result in environment syncronisation, so here we have an example of a workflow which will create a backup of the production environment and wait for it to complete before restoring the new backup to the target environment - in this case it's our dev environment.

CircleCI Configuration

version: 2.1

orbs:
skpr: skpr/skpr@1.3.2

jobs:
backup:
docker:
- image: skpr/cli:v0.18.0
steps:
- checkout
- setup_remote_docker:
version: "20.10.11"
docker_layer_caching: true
- skpr/backup:
target: prod
- skpr/restore:
source: prod
target: dev

workflows:
backup:
jobs:
- backup:
context: skpr-cluster-name
filters:
branches:
only: [ main ]