Skip to main content

GitHub Action: Push Repo to Cloudron App

Overview

Set up the GitHub Action: Cloudron Push to App to automatically deploy your application to a Cloudron instance when you push changes to your GitHub repository.

Example use case: deploying a custom web application to a Cloudron LAMP app on every push.

Example repository: cloudron-io/github-action-test-repo.

This repository contains a simple index.html, index.css, and composer.json file configured to use the GitHub Action. Copy the .github/workflows/deploy-to-cloudron.yaml file from this repository to get started quickly. Set up the GitHub Secrets as described below.

Setup Instructions

  1. Create a Cloudron API Token with read-write permissions and save it for the next step
  2. Add the API Token as a GitHub Secret
    1. Go to your GitHub repository
    2. Navigate to Settings > Environments
    3. Create a new environment with a name of your choice (e.g., cloudron-deploy) - each environment is for one Cloudron instance
    4. In the newly created environment, click Add environment secret and add the following secrets:
      1. CLOUDRON_FQDN: The FQDN of your Cloudron instance (e.g., my.demo.cloudron.io)
      2. CLOUDRON_TOKEN: The API token you created in step 1
      3. CLOUDRON_APP_ID: The App ID of the Cloudron app where you want to deploy your application. You can find the App ID in the Cloudron dashboard when configuring the app in the URL. Alternatively, you can also use the location e.g., lamp or fully qualified domain name e.g., lamp.demo.cloudron.io
  3. Create a GitHub Actions Workflow
    1. In your GitHub repository, create the folder .github/workflows if it doesn't already exist
    Bash
    mkdir -p .github/workflows
    1. Create a new file named deploy-to-cloudron.yaml.yml in the .github/workflows folder with the following content:
    deploy-to-cloudron.yaml
    # this is the rule when the action will be triggered - see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on
    # this rule triggers the action on every push to the main branch
    on:
    push:
    branches:
    - main
    jobs:
    # this is the job name definition - you can name it as you like
    deploy-to-cloudron-app:
    # this is the runner definition, you can think of this as the operating system where the job will run - here we use the ubuntu-latest
    runs-on: ubuntu-latest
    # the environment that we created in step 2
    environment: cloudron-deploy
    # the steps to execute in this job
    steps:
    # Name of the step and which action to use - here we checkout the repository code with https://github.com/actions/checkout
    - name: Checkout Repository
    uses: actions/checkout@v6
    # Name of the step and which action to use - here we use the Cloudron Push to App action
    - name: Cloudron Push to App
    uses: cloudron-io/cloudron-push-to-app@latest
    # the parameters/variables to pass to the action
    with:
    # secret CLOUDRON_FQDN that we created in step 2 for the environment cloudron-deploy
    CLOUDRON_FQDN: "${{ secrets.CLOUDRON_FQDN }}"
    # secret CLOUDRON_TOKEN that we created in step 2 for the environment cloudron-deploy
    CLOUDRON_TOKEN: "${{ secrets.CLOUDRON_TOKEN }}"
    # secret CLOUDRON_APP_ID that we created in step 2 for the environment cloudron-deploy
    CLOUDRON_APP_ID: "${{ secrets.CLOUDRON_APP_ID }}"
    # optional: specify the destination path in the Cloudron app where the files should be pushed - default is /app/data/public
    # the action will copy all files from the repository root to this destination path
    CLOUDRON_PUSH_DESTINATION: "/app/data/public"
    # optional: create a backup of the app before deploying - default is "true"
    CLOUDRON_CREATE_APP_BACKUP: "true"
  4. Commit and push the changes to your GitHub repository
  5. Monitor the GitHub Actions tab in your repository to see the deployment progress
Multiple Environments - Staging and Live

Create multiple environments (e.g., live and staging) with different CLOUDRON_FQDN, CLOUDRON_TOKEN, and CLOUDRON_APP_ID values. Use separate workflows that trigger on specific branches (e.g., develop for staging).

Customizing GitHub Action

Add steps to the workflow before the Cloudron Push to App step to prepare your application for deployment.

For example, install Composer dependencies before pushing to Cloudron:

deploy-to-cloudron.yaml
on:
push:
branches:
- main
jobs:
deploy-to-cloudron-app:
runs-on: ubuntu-latest
environment: my.cloudron.example
steps:
- name: Checkout Repository
uses: actions/checkout@v6
# Extra step to install composer dependencies
- name: Install composer dependencies
uses: php-actions/composer@v6
- name: Cloudron Push to App
uses: cloudron-io/cloudron-push-to-app@latest
with:
CLOUDRON_FQDN: "${{ secrets.CLOUDRON_FQDN }}"
CLOUDRON_TOKEN: "${{ secrets.CLOUDRON_TOKEN }}"
CLOUDRON_APP_ID: "${{ secrets.CLOUDRON_APP_ID }}"
CLOUDRON_PUSH_DESTINATION: "/app/data/public"
CLOUDRON_CREATE_APP_BACKUP: "true"