name: trigger-dev # Independent of app CI: task packaging and deployment must never delay dev images. on: push: branches: [dev] permissions: contents: read # Serialize promotions without cancelling an external deployment in flight. # Pending pushes coalesce to the newest run while the current run finishes. concurrency: group: deploy-trigger-dev cancel-in-progress: false jobs: deploy: name: deploy runs-on: ${{ (vars.CI_PROVIDER == '' || vars.CI_PROVIDER == 'blacksmith') && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-latest' }} timeout-minutes: 30 permissions: contents: read id-token: write steps: - name: Checkout code uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6 with: persist-credentials: false - name: Setup workspace uses: ./.github/actions/setup with: provider: ${{ vars.CI_PROVIDER }} node-version: '' # The deploy syncs an environment listed in `vars.TRIGGER_ENV_SYNC_TARGETS` from the app's # env-vars secret (see `@sim/runtime-secrets/trigger-env`), which needs read access to that secret. - name: Configure AWS credentials for the env sync if: contains(format(',{0},', vars.TRIGGER_ENV_SYNC_TARGETS), ',preview,') uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6 with: role-to-assume: ${{ secrets.DEV_AWS_ROLE_TO_ASSUME }} aws-region: ${{ secrets.DEV_AWS_REGION }} - name: Upload preview version id: deploy working-directory: ./apps/sim env: TRIGGER_ACCESS_TOKEN: ${{ secrets.TRIGGER_ACCESS_TOKEN_PREVIEW || secrets.TRIGGER_ACCESS_TOKEN }} TRIGGER_PROJECT_ID: ${{ secrets.TRIGGER_PROJECT_ID }} TRIGGER_ENV_SYNC_TARGETS: ${{ vars.TRIGGER_ENV_SYNC_TARGETS }} run: | set -euo pipefail : "${TRIGGER_ACCESS_TOKEN:?TRIGGER_ACCESS_TOKEN_PREVIEW or TRIGGER_ACCESS_TOKEN must be configured}" : "${TRIGGER_PROJECT_ID:?TRIGGER_PROJECT_ID must be configured}" bunx trigger.dev@4.8.3 deploy --env preview --branch dev-sim --skip-promotion - name: Promote current dev preview working-directory: ./apps/sim env: GH_TOKEN: ${{ github.token }} TRIGGER_ACCESS_TOKEN: ${{ secrets.TRIGGER_ACCESS_TOKEN_PREVIEW || secrets.TRIGGER_ACCESS_TOKEN }} TRIGGER_PROJECT_ID: ${{ secrets.TRIGGER_PROJECT_ID }} VERSION: ${{ steps.deploy.outputs.deploymentVersion }} run: | set -euo pipefail if ! [[ "$VERSION" =~ ^[0-9]{8}\.[0-9]+$ ]]; then echo "ERROR: Trigger.dev did not report a valid deploymentVersion output" >&2 exit 1 fi CURRENT_SHA=$(gh api "repos/$GITHUB_REPOSITORY/git/ref/heads/dev" --jq '.object.sha') if [ "$CURRENT_SHA" != "$GITHUB_SHA" ]; then echo "::notice::Skipping superseded dev task version $VERSION" exit 0 fi bunx trigger.dev@4.8.3 promote "$VERSION" --env preview --branch dev-sim