Integrating with CI/CD

You can deploy Akka Serverless services from a CI/CD (Continuous Integration/Continuous Delivery) service with the akkasls command. You need to create a script that installs akkasls and authenticates as an Akka Serverless account. To authenticate a CI/CD service, the script needs a refresh token.

You can use your own account in the script, or create a separate account tied to a different email address by inviting that address to your Akka Serverless project.

Creating a refresh token

Create a refresh token as follows:

  1. Log in to the account you want to authenticate.

  2. Create a refresh token with execution scope:

    akkasls auth tokens create --type=refresh --scopes=execution --description="My CI/CD token"

    The output will look similar to:

    Token created: cst1.832640ce01f08072e91e3c848eb0767763f94ba9f973fa127d0c285a74e88076
  3. Record the token and configure it in your CI/CD solution as a secret to be passed as an environment variable, for example, as AKKASLS_TOKEN.

The next section provides an example of how to use the variable.

Configuring akkasls in the CI/CD environment

To configure deployment with akkasls, write a script that runs in your CI/CD environment. You need the refresh token to be passed as an environment variable as described above. Additionally, you will need the id(s) of the project(s) you wish to work with.

The script needs the project id (a UUID), not the project name. Because the token has execution scope, it does not have permission to look up a list of projects for the account. We do not recommend widening the scope of the token to all, because it would give the CI/CD provider full permissions to do whatever they want with your project.

The example below assumes use of an AKKASLS_TOKEN environment variable for the refresh token, and an AKKASLS_PROJECT_ID environment variable for the project ID.

The following example script sets up continuous integration on a Linux machine. For other operating systems, see how to download and install akkasls.

# Download and install akkasls
tar -xzf akkasls_linux_amd64.tar.gz
mv akkasls /usr/local/bin

# Log in
akkasls config set refresh-token $AKKASLS_TOKEN

# Set the project to work with
akkasls config set project $AKKASLS_PROJECT_ID