GitHub Action: Push Repo to Cloudron App¶
Overview¶
This guide explains how to set up the GitHub Action: Cloudron Push to App to automatically push your application to a Cloudron instance app whenever you push changes to your GitHub repository.
As an example, you have a custom web application and want to deploy it to a Cloudron LAMP app whenever you push changes to your GitHub repository.
Example repository: cloudron-io/github-action-test-repo.
This repo contains a simple index.html, index.css and composer.json file and is configured to use the GitHub Action to push to a Cloudron app.
You can copy the .github/workflows/deploy-to-cloudron.yaml file from this repository to your own repository to get started quickly.
You will still need to set up the GitHub Secrets as described below.
- Action repository: cloudron-io/cloudron-push-to-app
- GitHub Marketplace: Cloudron Push to App
Setup Instructions¶
- Create a Cloudron API Token with read-write permissions and save it, you will need it in the next step
- Add the API Token as a GitHub Secret
- Go to your GitHub repository
- Navigate to
Settings>Environments - Create a new environment with a name of your choice (e.g.,
cloudron-deploy) - each environment is for one Cloudron instance - In the newly created environment, click
Add environment secretand add the following secrets:CLOUDRON_URL: The URL of your Cloudron instance (e.g.,my.demo.cloudron.io)CLOUDRON_TOKEN: The API token you created in step 1CLOUDRON_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.,lampor fully qualified domain name e.g.,lamp.demo.cloudron.io
- Create a GitHub Actions Workflow
- In your GitHub repository, create the folder
.github/workflowsif it doesn't already existBash - Create a new file named
deploy-to-cloudron.yaml.ymlin the.github/workflowsfolder with the following content:
- In your GitHub repository, create the folder
- Commit and push the changes to your GitHub repository
- Monitor the GitHub Actions tab in your repository to see the deployment progress
Multiple Environments - Staging and Live
You can also create multiple environments for e.g., live and staging and have a different CLOUDRON_URL, CLOUDRON_TOKEN and CLOUDRON_APP_ID and use the environments in another workflow that only triggers on a specific branch e.g., develop.
This way you can have a staging and live deployment setup
Customizing GitHub Action¶
You can add more steps to the GitHub Actions workflow before the Cloudron Push to App step to prepare your application for deployment.
For example, if your application requires Composer dependencies to be installed, you can add a step to install the dependencies before pushing the app to Cloudron: