GitHub Actions

Using GitHub Actions with Qovery is super powerful and gives you the ability to manage the way that you want to deploy your applications. As the possibility are endless, I will share with you a couple of examples that you can use. Feel free to adapt them to your need.

Prerequisites

Before using the examples below, you need to:

  1. Install the Qovery CLI.
  2. Generate an API token via the CLI or the Console .
  3. Set the environment variable Q_CLI_ACCESS_TOKEN or QOVERY_CLI_ACCESS_TOKEN (both are valid) with your API token. E.g. export QOVERY_CLI_ACCESS_TOKEN=your-api-token
  4. You have turned off the Qovery Auto Deployment for every service that you want to deploy manually.

GitHub Actions Examples

Deploy a container application

This example will deploy a container application with Qovery from your GitHub CI pipeline. Feel free to adapt it to your need.

.github/workflows/deploy-with-qovery.yml
# 1. Build and Push image to a remote registry
# 2. Deploy with Qovery
name: Publish Docker image and Deploy with Qovery
on:
release:
types: [published]
jobs:
deploy_with_qovery:
name: Push Docker image to Docker Hub and Deploy with Qovery
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Log in to Docker Hub
uses: docker/login-action
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action
with:
images: my-docker-hub-namespace/my-docker-hub-repository
- name: Build and push Docker image
uses: docker/build-push-action
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Deploy with Qovery
uses: actions/checkout@v3
env:
QOVERY_CLI_ACCESS_TOKEN: ${{ secrets.QOVERY_CLI_ACCESS_TOKEN }}
shell: bash
run: |
# Download and install Qovery CLI
curl -s https://get.qovery.com | bash
qovery container deploy \
--organization <your_org_name> \
--project <your_project_name> \
--environment <your_environment_name> \
--container <your_qovery_container_name> \
--tag ${{ github.sha }} \
--watch

Qovery CLI command examples

Deploy your application with a specific commit ID

qovery application deploy \
--organization <your_org_name> \
--project <your_project_name> \
--environment <your_environment_name> \
--application <your_app_name> \
--commit-id <your_commit_id> \
--watch

Deploy your multiple applications with a different commit ID

# deploy the application 1 and wait for the deployment to be successful with the --watch argument
qovery application deploy \
--organization <your_org_name> \
--project <your_project_name> \
--environment <your_environment_name> \
--application <your_app_1_name> \
--commit-id <your_commit_id> \
--watch
# deploy the application 2 and wait for the deployment to be successful with the --watch argument
qovery application deploy \
--organization <your_org_name> \
--project <your_project_name> \
--environment <your_environment_name> \
--application <your_app_2_name> \
--commit-id <your_commit_id> \
--watch

This is also applicable for the qovery container deploy, qovery lifecycle deploy, and qovery cronjob deploy commands.

Deploy your multiple applications with a specific commit ID (monorepo)

# deploy the application 1, 2 and 3 with the same commit ID and wait for the deployment to be successful with the --watch argument
qovery application deploy \
--organization <your_org_name> \
--project <your_project_name> \
--environment <your_environment_name> \
--applications "<app_1_name>, <app_2_name>, <app_3_name>" \
--commit-id <your_commit_id> \
--watch

This is also applicable for the qovery container deploy, qovery lifecycle deploy, and qovery cronjob deploy commands.

Create a Preview Environment for your Pull-Request

Qovery integrates automatically with GitHub, GitLab and Bitbucket to create a Preview Environment for each Pull-Request. But in case you want to control the creation of the Preview Environment manually, you can use the following commands:

# Clone your base environment
qovery environment clone \
--organization <your_org_name> \
--project <your_project_name> \
--environment <your_environment_name> \
--new-environment-name <your_new_environment_name>
# Change your application branch to the Pull-Request branch
qovery application update \
--organization <your_org_name> \
--project <your_project_name> \
--environment <your_new_environment_name> \
--application <your_app_name> \
--branch <your_pull_request_branch_name>
# Deploy your new environment
qovery environment deploy \
--organization <your_org_name> \
--project <your_project_name> \
--environment <your_new_environment_name> \
--watch

Delete a Preview Environment

qovery environment delete \
--organization <your_org_name> \
--project <your_project_name> \
--environment <your_preview_environment_name> \
--watch

Terraform

Do you want to include Terraform in your CI? Check out our Terraform documentation.

Any other examples?

Feel free to share your examples with us, and we'll be happy to share them with the community. Contact us on our forum.