from GitHub

Deployments with GitHub Actions #

Requirements #

  • You need to have a GitHub Account/organization
  • You need to create a deploy user on our platform
  • Add the following private variables to the repository or organization secrets on GitHub:
    • QUANTUM_USER - your deployment user name
    • QUANTUM_PASSWORD

Basic Setup #

GitHub Actions uses workflows to run commands based on events. In this example, we want to deploy a stack when a (GitHub) pull request is merged into the main branch.

The file’s path (in your repository) is: .github/workflows/deployment.yml.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
---
name: deployment

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest
    env:
      QUANTUM_USER: ${{ secrets.QUANTUM_USER }}
      QUANTUM_PASSWORD: ${{ secrets.QUANTUM_PASSWORD }}
      QUANTUM_ENDPOINT: "YOUR ENDPOINT"
      QUANTUM_STACK: "YOUR STACK"
    steps:
      - name: checkout code
        uses: actions/checkout@v2
      - name: quantum-cli
        run: |
          docker run \
          -v ${{ github.workspace }}:/work -w /work \
          -e QUANTUM_USER \
          -e QUANTUM_PASSWORD \
          -e QUANTUM_ENDPOINT \
          --rm r.planetary-quantum.com/quantum-public/cli:2 \
          quantum-cli stacks update --create --stack $QUANTUM_STACK --wait          
Remember to customize QUANTUM_ENDPOINT and QUANTUM_STACK above.

Setup with custom Docker images #

If you need to build custom images, you will need a private registry. It’s up to you if you want to run a registry yourself or take advantage of Quantum’s managed Docker Registry.

GitHub Packages offers a Docker registry as well. Follow this link to learn more.

Additionally to the above, add the registry user as private variables on the repository or organization secrets:

  • REGISTRY_USER
  • REGISTRY_PASSWORD

Add the following to the previous workflow to build and push a Docker image, before using quantum-cli to deploy it:

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
    steps:
      - name: checkout code
        uses: actions/checkout@v3
      - name: set up Docker Buildx
        uses: docker/setup-buildx-action@v2
      - name: Login to registry
        uses: docker/login-action@v2
        with:
          registry: registry.example.org
          username: ${{ secrets.REGISTRY_USER }}
          password: ${{ secrets.REGISTRY_PASSWORD }}
      - name: "build: application"
        uses: docker/build-push-action@v3
        with:
          context: .
          push: true
          file: Dockerfile
          tags: registry.example.org/project/app:latest