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:
- Install the Qovery CLI.
- Generate an API token via the CLI or the Console .
- Set the environment variable
Q_CLI_ACCESS_TOKEN
orQOVERY_CLI_ACCESS_TOKEN
(both are valid) with your API token. E.g.export QOVERY_CLI_ACCESS_TOKEN=your-api-token
- You have turned off the Qovery Auto Deployment for every service that you want to deploy manually.
GitHub Actions Examples
Deploy a container application
Before you begin, this page assumes the following:
- You have connected your Container Registry with Qovery.
- You have a container application that you want to deploy on Qovery.
- You have set the
QOVERY_CLI_ACCESS_TOKEN
environment variable in your GitHub Actions project.
This example will deploy a container application with Qovery from your GitHub CI pipeline. Feel free to adapt it to your need.
# 1. Build and Push image to a remote registry# 2. Deploy with Qoveryname: Publish Docker image and Deploy with Qoveryon:release:types: [published]jobs:deploy_with_qovery:name: Push Docker image to Docker Hub and Deploy with Qoveryruns-on: ubuntu-lateststeps:- name: Check out the repouses: actions/checkout@v3- name: Log in to Docker Hubuses: docker/login-actionwith:username: ${{ secrets.DOCKER_USERNAME }}password: ${{ secrets.DOCKER_PASSWORD }}- name: Extract metadata (tags, labels) for Dockerid: metauses: docker/metadata-actionwith:images: my-docker-hub-namespace/my-docker-hub-repository- name: Build and push Docker imageuses: docker/build-push-actionwith:context: .push: truetags: ${{ steps.meta.outputs.tags }}labels: ${{ steps.meta.outputs.labels }}- name: Deploy with Qoveryuses: actions/checkout@v3env:QOVERY_CLI_ACCESS_TOKEN: ${{ secrets.QOVERY_CLI_ACCESS_TOKEN }}shell: bashrun: |# Download and install Qovery CLIcurl -s https://get.qovery.com | bashqovery 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 argumentqovery 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 argumentqovery 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 argumentqovery 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 environmentqovery 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 branchqovery 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 environmentqovery 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.