|
| 1 | +--- |
| 2 | +title: GitHub Actions Integration |
| 3 | +description: Deploy with FTL using GitHub Actions workflows |
| 4 | +--- |
| 5 | + |
| 6 | +# GitHub Actions Integration |
| 7 | + |
| 8 | +Deploy your applications automatically using FTL and GitHub Actions. The official FTL GitHub Action handles installation, SSH setup, and deployment in your CI/CD pipeline. |
| 9 | + |
| 10 | +## Quick Start |
| 11 | + |
| 12 | +Add the FTL Deploy action to your workflow: |
| 13 | + |
| 14 | +```yaml |
| 15 | +name: Deploy |
| 16 | + |
| 17 | +on: |
| 18 | + push: |
| 19 | + branches: [main] |
| 20 | + |
| 21 | +jobs: |
| 22 | + deploy: |
| 23 | + runs-on: ubuntu-latest |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - name: Deploy with FTL |
| 28 | + uses: yarlson/ftl-deploy-action@v1 |
| 29 | + with: |
| 30 | + ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} |
| 31 | + env: |
| 32 | + DATABASE_URL: ${{ secrets.DATABASE_URL }} |
| 33 | +``` |
| 34 | +
|
| 35 | +## Setup |
| 36 | +
|
| 37 | +### 1. Prepare SSH Key |
| 38 | +
|
| 39 | +Generate a dedicated SSH key for deployments: |
| 40 | +
|
| 41 | +```bash |
| 42 | +ssh-keygen -t ed25519 -C "github-deploy" -f ~/.ssh/ftl_github |
| 43 | +``` |
| 44 | + |
| 45 | +Add the public key to your server's `~/.ssh/authorized_keys`. |
| 46 | + |
| 47 | +### 2. Add SSH Key to GitHub Secrets |
| 48 | + |
| 49 | +1. Go to repository Settings → Secrets and variables → Actions |
| 50 | +2. Click "New repository secret" |
| 51 | +3. Name: `SSH_PRIVATE_KEY` |
| 52 | +4. Value: Contents of `~/.ssh/ftl_github` (complete file) |
| 53 | + |
| 54 | +### 3. Create Workflow File |
| 55 | + |
| 56 | +Create `.github/workflows/deploy.yml` in your repository with the deployment workflow. |
| 57 | + |
| 58 | +## Common Patterns |
| 59 | + |
| 60 | +### Deploy on Tag |
| 61 | + |
| 62 | +Deploy when you create a release tag: |
| 63 | + |
| 64 | +```yaml |
| 65 | +on: |
| 66 | + push: |
| 67 | + tags: |
| 68 | + - "v*" |
| 69 | +``` |
| 70 | +
|
| 71 | +### Deploy Staging and Production |
| 72 | +
|
| 73 | +Use different workflows or environments: |
| 74 | +
|
| 75 | +```yaml |
| 76 | +jobs: |
| 77 | + deploy-staging: |
| 78 | + if: github.ref == 'refs/heads/develop' |
| 79 | + # ... deploy to staging |
| 80 | + |
| 81 | + deploy-production: |
| 82 | + if: github.ref == 'refs/heads/main' |
| 83 | + # ... deploy to production |
| 84 | +``` |
| 85 | + |
| 86 | +### First Deployment |
| 87 | + |
| 88 | +For initial server setup, enable `run-setup`: |
| 89 | + |
| 90 | +```yaml |
| 91 | +- uses: yarlson/ftl-deploy-action@v1 |
| 92 | + with: |
| 93 | + ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} |
| 94 | + run-setup: "true" |
| 95 | +``` |
| 96 | +
|
| 97 | +After the first deployment, remove or set to `'false'`. |
| 98 | +
|
| 99 | +## Action Reference |
| 100 | +
|
| 101 | +See the complete [action documentation](https://github.com/yarlson/ftl-deploy-action) for all inputs and advanced usage patterns. |
| 102 | +
|
| 103 | +## Troubleshooting |
| 104 | +
|
| 105 | +### Action Fails with SSH Error |
| 106 | +
|
| 107 | +Verify your SSH key in GitHub Secrets includes the complete key including BEGIN/END markers: |
| 108 | +
|
| 109 | +``` |
| 110 | +-----BEGIN OPENSSH PRIVATE KEY----- |
| 111 | +... |
| 112 | +-----END OPENSSH PRIVATE KEY----- |
| 113 | +``` |
| 114 | + |
| 115 | +### Build Fails on Runner |
| 116 | + |
| 117 | +Ensure your Dockerfile and build context are correctly configured in `ftl.yaml`. The action uses the same build process as local FTL. |
| 118 | + |
| 119 | +### Environment Variables Not Working |
| 120 | + |
| 121 | +Make sure environment variables are passed in the `env` section of the action step, not as `with` inputs. |
| 122 | + |
| 123 | +## Next Steps |
| 124 | + |
| 125 | +- [Configure health checks](/guides/health-checks) for zero-downtime deployments |
| 126 | +- [Set up monitoring](/core-tasks/logging) with FTL logs |
| 127 | +- [Review security best practices](/guides/security) |
0 commit comments