Deploy from GitHub

Deploy from GitHub

How to set up you CI/CD from GitHub directly from Clever Cloud, and how to deploy review apps.

Use the GitHub integration

Clever Cloud provides a GitHub integration to deploy any repository hosted on GitHub to Clever Cloud. You can deploy the same repository to multiple Clever Cloud applications from different branches. Select the appropriate branch in you application menu, in Information > Application edition > Used GitHub branch for deployment.

GitHub branch deployment

Clever Cloud asks for permission to access your GitHub repositories. Accept the permissions to allow the deployment. You can deploy both public or private repositories.

Deploy review apps from a PR on GitHub

You can automate deployments for review apps when a Pull Request opens on your GitHub repository by using Clever Cloud GitHub Action. This action uses Clever Tools to deploy a new app from the branch the Pull Request is based on and post a comment with the URL of the review app. The action redeploys the app on every new commit and deletes it when the Pull Request is closed (merged or not).

How to use the Review App GitHub Action

Two things are necessary to use the action:

  1. A workflow file to run the action. For example, .github/workflow/review-app.yml. At the top of this file, define the event trigger for running the action:
on:
  pull_request_target:
    types: [opened, closed, synchronize, reopened]
    branches: [ main ]

Then, use the action and define the mandatory input:

- name: Create review app
        uses: CleverCloud/clever-cloud-review-app@latest
        env:
          CLEVER_SECRET: ${{ secrets.CLEVER_SECRET }}
          CLEVER_TOKEN: ${{ secrets.CLEVER_TOKEN }}
          ORGA_ID: ${{ secrets.ORGA_ID }}
        with:
          type: '<type-of-app>'
  1. Inject the environment variables from your repository: From your GitHub repository go to Settings > Secrets and variables. Inject them both in “Environment secrets” and “Repository secrets” to allow deployments from forked repositories. Then add them with an GH_ prefix in your workflow file (this will prevent the injection of the GitHub runner variables in your app). Finally, enable the injection with set-env: true:
name: Create review app
        uses: CleverCloud/clever-cloud-review-app@latest
        env:
          CLEVER_SECRET: ${{ secrets.CLEVER_SECRET }}
          CLEVER_TOKEN: ${{ secrets.CLEVER_TOKEN }}
          ORGA_ID: ${{ secrets.ORGA_ID }}
          GH_CC_RUN_SUCCEEDED_HOOK: ${{ secrets.CC_RUN_SUCCEEDED_HOOK }} # This environment variable will be set on Clever Cloud
        with:
          type: '<type-of-app>'
          set-env: true # Enables the command to set en vars on Clever Cloud

Mandatory configuration

Your repository must contain at least the following variables to use the CLI:

  • CLEVER_TOKEN
  • CLEVER_SECRET

Find it in your machine, usually in ~/.config/clever-cloud/clever-tools.json, after installing Clever Tools.

⚠️ CLEVER_TOKEN and CLEVER_SECRET expire after one year. Make sure to set a reminder to inject the new ones to avoid breaking your pipelines.

Full instructions are available on the Action project.

Review App workflow example

To see a Review App workflow already in use, see this workflow on GitHub.

Troubleshooting

If you encounter troubles or bugs using the GitHub Action, feel free to open an issue on the repository.

🎓 Go further

Last updated on

Did this documentation help you ?