CI/CD with CircleCI

Use the akkaserverless orb to use CircleCI with your Akka Serverless project. The orb supports commands for installing, authenticating, and invoking the Akka Serverless CLI.

Prerequisites

To use the akkaserverless orb, you’ll need to:

Create an authentication context

The akkaserverless orb expects the authentication token and project ID as parameters. CircleCI context new tab allows you to store the authentication token and project ID values securely using a context.

In your CircleCI account, create a context new tab and:

  1. Store the authentication token as AKKASLS_TOKEN.

  2. Store the project ID as AKKASLS_PROJECT.

With the authentication variables saved, you can use them in your project configuration.

Create a workflow

Follow these steps to create a workflow to invoke the akkaserverless orb for your project:

  1. Create a folder named .circleci at the root of the project folder.

  2. Create a file named config.yml in the .circleci folder.

  3. Open config.yml for editing and add the CircleCI version:

    version: 2.1
  4. Reference the orb:

    orbs:
      akkaserverless: lightbend-labs/akkaserverless@1.0.0
  5. Add a job that creates an image and invokes orb commands. For example, to deploy a service named my-service:

    jobs:
      run-akkasls:
        docker:
          - image: 'cimg/base:stable'
        steps:
          - checkout
          - akkaserverless/install (1)
          - akkaserverless/exec: (2)
              cmd: services deploy my-service cimg/base:stable
    1 The akkaserverless/install command installs the Akka Serverless CLI for your CircleCI job and configures it using the AKKASLS_TOKEN and AKKASLS_PROJECT environment variables set in the CircleCI context.
    2 The akkaserverless/exec command executes any command from the Akka Serverless CLI. Do not precede commands with akkasls.
  6. Add a workflow new tab to schedule the job and give it access to the context storing the authentication variables. For example, with a refresh token and project ID stored in akkasls-context:

    workflows:
      version: 1
      install-and-run-akkasls:
        jobs:
          - run-akkasls
          context:
          - akkasls-context

    By default, CircleCI jobs are triggered by any push to the repository. See the documentation for scheduling new tab a workflow.

  7. Save .config.yml.