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_API_KEY- your deployment api key
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. To get this done, we are using the hostwithquantum/setup-quantum-cli Github Action!
The file’s path (in your repository) is: .github/workflows/deployment.yml.
| |
Remember to customizeQUANTUM_ENDPOINTandQUANTUM_STACKabove.
Configure Dependabot to receive updates for our actions:
# .github/dependabot.yml version: 2 updates: - package-ecosystem: "github-actions" directory: "/" schedule: interval: "weekly" groups: actions-deps: patterns: - "*" cooldown: default-days: 7
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.
In addition to the example above, add the registry credentials as repository or organization secrets:
REGISTRY_USERREGISTRY_PASSWORD
Add the following to the previous workflow to build and push a Docker image, before using quantum-cli to deploy it:
| |
Avoid using
:latestand inject a version into your stack. To do so, set an environment variable with the output fromdocker/metadata-actionbefore you deploy:- run: echo "VERSION=${{ steps.meta.output.version }}" >> $GITHUB_ENVIn the stack/compose file, use this as an example:
image: registry.example.org/project/app:$VERSION.