Skip to content

GitHub Actions

Nullstone offers automatic builds and deploys; however, some teams prefer to build and deploy through their own CI/CD. This guide shows how to configure GitHub Actions to push and deploy new versions of your code.

TIP

Nullstone provides an action to set up Nullstone. Check out the Setup Nullstone Action documentation for detailed reference.

Configure Nullstone access

  1. Create a Nullstone API Key. Visit your Nullstone Profile and add a new API Key. Name it GitHub.

  2. Add API key secret to your GitHub repo. Visit the desired GitHub repository and navigate to the Settings tab. Open the Secrets > Actions screen. Click New repository secret. Name: NULLSTONE_API_KEY Value: <Copy value from Step 1>

Deploy app using Nullstone CLI

To deploy an app, use the Nullstone CLI tool. Nullstone provides a GitHub action to install the latest version of the CLI. Then, add workflow steps to issue commands against the CLI to perform the deployment.

TIP

The Nullstone CLI tool is configured to use the NULLSTONE_ORG and NULLSTONE_API_KEY environment variables.

yaml
env:
  NULLSTONE_ORG: <your org in nullstone>
  NULLSTONE_APP: <app>

jobs:
  build:
    # ... Build docker image here
  deploy:
    name: Deploy app
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: nullstone-io/setup-nullstone-action@v0
      - name: Push
        env:
          NULLSTONE_ENV: <env>
        run: |
          nullstone push --source=<docker image built above>
      - name: Deploy
        env:
          NULLSTONE_ENV: <env>
        run: |
          nullstone deploy
env:
  NULLSTONE_ORG: <your org in nullstone>
  NULLSTONE_APP: <app>

jobs:
  build:
    # ... Build docker image here
  deploy:
    name: Deploy app
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: nullstone-io/setup-nullstone-action@v0
      - name: Push
        env:
          NULLSTONE_ENV: <env>
        run: |
          nullstone push --source=<docker image built above>
      - name: Deploy
        env:
          NULLSTONE_ENV: <env>
        run: |
          nullstone deploy

Publish infra module using Nullstone CLI

Nullstone provides a simple workflow for making changes to your infrastructure through Terraform. When making changes to Terraform, you must publish these changes through Nullstone modules published in the Nullstone registry. This step walks you through setting up the Nullstone CLI tool in GitHub Actions to publish module changes to Nullstone.

Nullstone provides a GitHub action to install the latest version of the CLI. Then, add workflow steps to issue commands against the CLI to publish the module.

WARNING

Make sure the module is registered in Nullstone and the repository contains .nullstone/module.yaml in the repository.

yaml
name: Nullstone
on:
  push:
    tags:
      - 'v*'

env:
  NULLSTONE_ORG: nullstone
  NULLSTONE_API_KEY: ${{ secrets.NULLSTONE_API_KEY }}

jobs:
  publish:
    runs-on: ubuntu-latest

    defaults:
      run:
        shell: bash

    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Set up Nullstone
        uses: nullstone-io/setup-nullstone-action@v0

      - name: Find version
        id: version
        run: echo "MODULE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV

      - id: publish
        name: Publish
        run: |
          nullstone modules publish --version=${{ env.MODULE_VERSION }}
name: Nullstone
on:
  push:
    tags:
      - 'v*'

env:
  NULLSTONE_ORG: nullstone
  NULLSTONE_API_KEY: ${{ secrets.NULLSTONE_API_KEY }}

jobs:
  publish:
    runs-on: ubuntu-latest

    defaults:
      run:
        shell: bash

    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Set up Nullstone
        uses: nullstone-io/setup-nullstone-action@v0

      - name: Find version
        id: version
        run: echo "MODULE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV

      - id: publish
        name: Publish
        run: |
          nullstone modules publish --version=${{ env.MODULE_VERSION }}