GitHub
๐
Connect your GitHub repositories.
Learn how the most popular Git-as-a-service provider is integrated with fortrabbit.
About GitHub
You hopefully already know that GitHub (by Microsoft) is the most popular choice for versionized code hosting and collaborating. It is free to use to some extend. Similar alternatives are 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 services tightly integrate with GitHub. Install the fortrabbit GitHub app to connect GitHub repos with apps hosted on fortrabbit. 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 is also offering Github Actions, an integrated continuous integration solution. Combining GitHub Actions with fortrabbit can help to integrate even more advanced CI/CD workflows. fortrabbit does not offer predefined GitHub Actions (currently), 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 needs SSH access to push files to fortrabbit. The recommended approach is a dedicated key pair used only for this purpose: the public key is registered as a deploy key on the fortrabbit app, the private key is stored as an encrypted secret in GitHub and injected into the workflow 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
# Deloy
- 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.