This GitHub Action does the following
- A PR is opened: it deploys the branch to be reviewed on Clever Cloud and posts a comment with the review app link
 - The PR is updated: it deploys last pushed commit and post a comment to confirm the redeployment
 - The PR is closed (merged or not): it deletes app and post a comment to confirm the job has been done.
 
The action will consider both branches on the same repository, and pull requests from forks.
- A Clever Cloud account
 - Clever Tools installed in your machine to get your tokens
 
You need to add tokens as secrets in your GitHub repository settings (Secrets and variables > Actions):
CLEVER_SECRETandCLEVER_TOKEN: find them in your~/.config/clever-cloud/clever-tools.jsonif you're logged inORGA_ID: the organisation in which the review apps should be createdGITHUB_TOKEN: implicit, to enable comments on the PR
For better security, we advise generating a specific CLEVER_SECRET and CLEVER_TOKEN for GitHub Actions, following these steps:
- Create a new user with a new e-mail address on Clever Cloud
 - Create a specific organisation for deploying review apps
 - From your terminal, run 
clever logoutandclever loginright after - Log into the Console with your new user credentials
 - Get the generated 
CLEVER_SECRETandCLEVER_TOKENand inject it into your repository secrets 
Run clever login again and connect from your main account to set your personal tokens. Your GitHub Action user's tokens won't be revoked and will be used only from GitHub.
- View and revoke OAuth tokens from the Clever Cloud Console
 
At job level, set the appropriate permissions to enable comments on PRs:
jobs:
  deploy:
    name: Deploy/redeploy review app
    runs-on: ubuntu-latest
    permissions:
        issues: write
        pull-requests: write
        contents: read- In your 
.github/workflow/review-app.yml, define the event trigger for running the action: 
on:
  pull_request:
    types: [opened, closed, synchronize, reopened]
    branches: [ main ]- Then, define the mandatory input:
 
- name: Create review app
        uses: CleverCloud/[email protected]
        env:
          CLEVER_SECRET: ${{ secrets.CLEVER_SECRET }}
          CLEVER_TOKEN: ${{ secrets.CLEVER_TOKEN }}
          ORGA_ID: ${{ secrets.ORGA_ID }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          type: '<type-of-app>'Choose one of the runtimes that Clever Cloud supports to deploy your review app:
dockerelixirfrankenphpgogradlehaskelljarlinuxmavenmeteornodephpplay1play2pythonrubyrustsbtstaticstatic-apachevwar
Use a specific flavor to scale your review app, and build-flavor to use a dedicated build instance on a different flavor:
- name: Create review app
        uses: CleverCloud/[email protected]
        with:
          type: '<type-of-app>'
          flavor: '<flavor>'
          build-flavor: '<build-flavor>'Available flavors: pico, nano, XS, S, M, L, XL, 2XL, 3XL
Flavor pico is not available for the following instances: docker, frankenphp, php, static-apache
To inject your app secrets and environment variables on Clever Cloud, add them to your GitHub repository settings in Secrets and variables > Actions, then add them with a GH_ prefix in your workflow file. Finally, enable the injection with set-env: true:
name: Create review app
        uses: CleverCloud/[email protected]
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # To enable comments on the PR
          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 CloudYou can override default options by defining region, domain, name, and alias. Default values are:
region=par(Paris)domain=<repo-name>-PR-#.cleverapps.io
par(Paris, Clever Cloud)parhds(Paris, HDS infrastructure, Clever Cloud)scw(Paris, Scaleway DC5)grahds(Gravelines, HDS infrastructure, OVHcloud)ldn(London, Ionos)mtl(Montreal, OVHcloud)rbx(Roubaix, OVHcloud)rbxhds(Roubaix, HDS infrastructure, OVHcloud)sgp(Singapore, OVHcloud)syd(Sydney, OVHcloud)wsw(Warsaw, OVHcloud)