GitHub
Reviewedbyfl
🐙
Connect your GitHub repositories.
Learn how the most popular Git-as-a-service provider is integrated with fortrabbit.
About GitHub
GitHub (by Microsoft) is the most popular web-based Git hosting platform for version control and team collaboration. It offers free accounts for open-source projects and unlimited public repositories, and serves as a central tool for developers to store, manage, and share code. Similar alternatives include Bitbucket and GitLab.
GitHub is not Git: GitHub is so popular that beginners sometimes confuse GitHub with Git. Git is the version control system; GitHub provides Git hosting plus collaboration features. If you're new to Git, check out our getting started with Git article.
Built-in GitHub integration
fortrabbit provides a built-in GitHub integration that connects your GitHub repositories directly to your deployed apps, enabling automatic deployments when you push code. This integration includes automatic stack detection, deployment configuration, and support for build and post-deploy commands. Install the fortrabbit GitHub app to set this up, and see the deployment intro to get started.
The built-in GitHub integration is easiest way to enable automatic deployments on git push. It includes automatic stack detection and software templates to auto-configure build commands, post-deploy commands and other deployment related settings.
Using GitHub Actions
GitHub Actions is a native CI/CD platform integrated into GitHub that automates testing, building, and deployment workflows. You can combine GitHub Actions with fortrabbit to create advanced deployment pipelines using SSH-based connections or other deployment methods. fortrabbit does not offer predefined GitHub Actions, but this blog post contains two templates to get started.
To use GitHub Actions, disable the built-in integration. Use rsync or some other SSH based workflow to deploy code to the web space.
Provide GitHub Actions code access
GitHub Actions requires SSH access to deploy code to fortrabbit, and the recommended approach uses a dedicated SSH key pair: the public key is stored as a deploy key on the fortrabbit app, while the private key is stored securely as an encrypted secret in GitHub and injected into workflows at runtime.
- On your local machine, generate a dedicated key pair:
ssh-keygen -t ed25519 -f /tmp/key-github -N "" - In the fortrabbit dashboard, open the app and add the public key (
/tmp/key-github.pub) as an App-only SSH key. - On GitHub, go to the repository → Settings → Secrets and variables → Actions and add a new secret named
SSH_PRIVATE_KEYwith the contents of the private key (/tmp/key-github). - Delete both key files from
/tmponce done.
Example: deploy via rsync
This workflow builds assets with Node.js, installs Composer dependencies, and deploys the result to fortrabbit via rsync.
.github/workflows/deploy.yml:
name: Deploy to fortrabbit
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest
env:
DESTINATION: '{{app-env-id}}@ssh.{{region}}.frbit.app'
steps:
- uses: actions/checkout@v4
- name: Set up SSH
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
- name: Install Node dependencies and build
run: |
npm ci
npm run build
- name: Remove source assets
run: rm -rf <your-source-assets-folder>
# Install PHP dependencies
- name: Install Composer dependencies
run: |
composer validate
composer install --prefer-dist --no-dev --no-progress --optimize-autoloader --ignore-platform-reqs
# Deploy
- name: Deploy via rsync
run: |
rsync -azh -e 'ssh -o StrictHostKeyChecking=no' \
./ \
--rsync-path='rsync' \
$DESTINATION:~/
- Replace
DESTINATIONwith your SSH address (found in the fortrabbit dashboard). StrictHostKeyChecking=nooption skips host verification on first connect; to avoid this you can add fortrabbit's host key to aknown_hostsfile in your workflow instead.