Deploy with Trigger.dev #10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy with Trigger.dev | |
on: | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: 'Select the deployment environment' | |
type: 'choice' | |
required: true | |
default: 'staging' | |
options: | |
- prod | |
- staging | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
# Automatically checkout the same branch/tag from "Use workflow from" dropdown | |
ref: ${{ github.ref_name }} | |
- name: Setup Node.JS v20 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
# Dynamically set TRIGGER_SECRET_KEY from the correct secrets based on whether 'prod' or 'staging' was chosen. | |
- name: Configure environment variables | |
run: | | |
if [ "${{ github.event.inputs.environment }}" = "prod" ]; then | |
echo "TRIGGER_SECRET_KEY=${{ secrets.TRIGGER_SECRET_KEY_PROD }}" >> $GITHUB_ENV | |
else | |
echo "TRIGGER_SECRET_KEY=${{ secrets.TRIGGER_SECRET_KEY_STAGING }}" >> $GITHUB_ENV | |
fi | |
# TRIGGER_ACCESS_TOKEN (same for both) | |
echo "TRIGGER_ACCESS_TOKEN=${{ secrets.TRIGGER_ACCESS_TOKEN }}" >> $GITHUB_ENV | |
- name: Run deploy command | |
run: npx trigger.dev@latest deploy -e ${{ github.event.inputs.environment }} |