--- title: "GitHub Actions" description: "You can easily deploy your tasks with GitHub actions." --- This simple GitHub action file will deploy your Trigger.dev tasks when new code is pushed to the `main` branch and the `trigger` directory has changes in it. The deploy step will fail if any version mismatches are detected. Please see the [version pinning](/v3/github-actions#version-pinning) section for more details. ```yaml .github/workflows/release-trigger-prod.yml name: Deploy to Trigger.dev (prod) on: push: branches: - main paths: - "trigger/**" jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - 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@beta deploy ``` ```yaml .github/workflows/release-trigger-staging.yml name: Deploy to Trigger.dev (staging) # Requires manually calling the workflow from a branch / commit to deploy to staging on: workflow_dispatch: jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - 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@beta deploy --env staging ``` If you already have a GitHub action file, you can just add the final step "🚀 Deploy Trigger.dev" to your existing file. You need to add the `TRIGGER_ACCESS_TOKEN` secret to your repository. You can create a new access token by going to your profile page and then clicking on the ["Personal Access Tokens"](https://cloud.trigger.dev/account/tokens) tab. To set it in GitHub go to your repository, click on "Settings", "Secrets and variables" and then "Actions". Add a new secret with the name `TRIGGER_ACCESS_TOKEN` and use the value of your access token. 1. Go to your repository on GitHub. 2. Click on "Settings". 3. Click on "Secrets and variables" -> "Actions" 4. Click on "New repository secret". 5. Add the name `TRIGGER_ACCESS_TOKEN` and the value of your access token. ![Add TRIGGER_ACCESS_TOKEN in GitHub](/images/v3/github-access-token.png) ## Version pinning The CLI and `@trigger.dev/*` package versions need to be in sync, otherwise there will be errors and unpredictable behavior. Hence, the `deploy` command will automatically fail during CI on any version mismatches. Tip: add the deploy command to your `package.json` file to keep versions managed in the same place. For example: ```json { "scripts": { "deploy:trigger-prod": "npx trigger.dev@3.0.0-beta.34 deploy", "deploy:trigger": "npx trigger.dev@3.0.0-beta.34 deploy --env staging" } } ``` Your workflow file will follow the version specified in the `package.json` script, like so: ```yaml .github/workflows/release-trigger.yml - name: 🚀 Deploy Trigger.dev env: TRIGGER_ACCESS_TOKEN: ${{ secrets.TRIGGER_ACCESS_TOKEN }} run: | npm run deploy:trigger ``` You should use the version you run locally during dev and manual deploy. The current version is displayed in the banner, but you can also check it by appending `--version` to any command.