CI / GitHub Actions
Automate deployments with GitHub Actions.
Production Deploy
Deploys to production on push to main:
yaml
# .github/workflows/release-trigger-prod.yml
name: Deploy to Trigger.dev (prod)
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: "20.x"
- name: Install dependencies
run: npm install
- name: Deploy Trigger.dev
env:
TRIGGER_ACCESS_TOKEN: ${{ secrets.TRIGGER_ACCESS_TOKEN }}
run: npx trigger.dev@latest deployPreview Branches (Pull Requests)
yaml
# .github/workflows/trigger-preview-branches.yml
name: Deploy to Trigger.dev (preview)
on:
pull_request:
types: [opened, synchronize, reopened, closed]
jobs:
deploy-preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20.x"
- run: npm install
- name: Deploy preview branch
run: npx trigger.dev@latest deploy --env preview
env:
TRIGGER_ACCESS_TOKEN: ${{ secrets.TRIGGER_ACCESS_TOKEN }}WARNING
Include closed in pull_request.types. Without it, preview branches won't be archived on PR close.
Adding TRIGGER_ACCESS_TOKEN to GitHub
- Go to Personal Access Tokens in Trigger.dev
- Create a new token
- In GitHub repo: Settings → Secrets → Actions → New repository secret
- Name:
TRIGGER_ACCESS_TOKEN, Value: your token
CLI Version Pinning
Pin trigger.dev in package.json to avoid version mismatch errors:
json
{
"scripts": {
"deploy:trigger": "trigger deploy",
"deploy:trigger-staging": "trigger deploy --env staging"
},
"devDependencies": {
"trigger.dev": "4.0.2"
}
}Then in the workflow:
yaml
- name: Deploy
env:
TRIGGER_ACCESS_TOKEN: ${{ secrets.TRIGGER_ACCESS_TOKEN }}
run: npm run deploy:triggerSelf-hosting
yaml
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: latest
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Deploy
env:
TRIGGER_ACCESS_TOKEN: ${{ secrets.TRIGGER_ACCESS_TOKEN }}
TRIGGER_API_URL: ${{ secrets.TRIGGER_API_URL }}
run: npx trigger.dev@latest deploy