Development

Deploying with the Skpr Github Action

By Kim Pepper15 April 2021

Many development teams have embraced the convenience of using Github Actions for their CI/CD workflows. You can now save time and effort by using the Skpr Deploy Github Action in your deploy workflow.

1. Set up credentials

In your Github project settings, add SKPR_USERNAME and SKPR_PASSWORD you were provided as Action Secrets.

2. Create a Github Action workflow

In your project add a .github/workflows/deploy-dev.yml file with the following contents:

name: deploy-dev
on:
  push:
    branches: [master]
env:
  SKPR_USERNAME: ${{ secrets.SKPR_USERNAME }}
  SKPR_PASSWORD: ${{ secrets.SKPR_PASSWORD }}

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Code
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Skpr Package and Deploy
        uses: skpr/package-deploy
        with:
          env: dev
          post-deploy: make deploy

We will break this example down and explain each section.

Deploying to each environment will require a separate workflow. In this example, we want to deploy to the dev environment whenever code is pushed to the master branch.

on:
  push:
    branches: [master]

We supply our Skpr credentials as environment variables taken from the Secrets we added in step 1.

env:
  SKPR_USERNAME: ${{ secrets.SKPR_USERNAME }}
  SKPR_PASSWORD: ${{ secrets.SKPR_PASSWORD }}

We next define our jobs running on a standard Ubuntu machine image:

jobs:
  deploy:
    runs-on: ubuntu-latest

Our first step simply checks out our code. We need to provide fetch-depth: 0 as we generate the version based off git describe --tags and need the full git history for that.

    steps:
      - name: Checkout Code
        uses: actions/checkout@v2
        with:
          fetch-depth: 0

Now to the Skpr specific configuration. We simply declare our skpr/package-deploy Action and provide it with two configuration options:

  • env: the Skpr environment we want to deploy to.
  • post-deploy: the commands we want to run on this environment immediately after deploy.
      - name: Skpr Package and Deploy
        uses: skpr/package-deploy
        with:
          env: dev
          post-deploy: make deploy

Deploying an existing packaged version

Some workflows will require an approval step (e.g. staging) and then deploy the exact same version to a production environment.

This requires listening for the workflow_dispatch event and taking the env and version parameters as inputs.

on:
  workflow_dispatch:
    inputs:
      env:
        description: The environment to deploy to
        required: true
        default: dev
      version:
        description: The version. Must be an existing packaged version.
        required: true

We can skip the package step in our step definition, and use the env and version parameters here.

      - name: Skpr Deploy
        uses: skpr/package-deploy
        with:
          env: ${{ github.event.inputs.env }}
          version: ${{ github.event.inputs.version }}
          package: false
          post-deploy: make deploy

Here's the full example of a prod deployment workflow, where the application was packaged in a previous workflow.

name: deploy-prod
on:
  workflow_dispatch:
    inputs:
      env:
        description: The environment to deploy to
        required: true
        default: dev
      version:
        description: The version. Must be an existing packaged version.
        required: true

env:
  SKPR_USERNAME: ${{ secrets.SKPR_USERNAME }}
  SKPR_PASSWORD: ${{ secrets.SKPR_PASSWORD }}

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Code
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Skpr Deploy
        uses: skpr/package-deploy
        with:
          env: ${{ github.event.inputs.env }}
          version: ${{ github.event.inputs.version }}
          package: false
          post-deploy: make deploy

You can trigger a deploy to prod directly from the Actions page in your Github project by specifying the environment and version parameters.

As you can see, deploying to Skpr using the Skpr Github Action is easy and intuitive, and will suit development teams who are considering using Github Actions for their CI/CD workflows.

Tags

deploying
github action

Getting Started

Interested in a demo?

🎉 Awesome!

Please check your inbox for a confirmation email. It might take a minute or so.

🤔 Whoops!

Something went wrong. Check that you have entered a valid email and try submitting the form again.

We'll be in touch shortly.