name: dagger
on:
  push:
    branches: [main]

jobs:
  build:
    name: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 16
      - name: Install deps
        run: npm ci
      - name: Install Dagger CLI
        run: cd /usr/local && { curl -L https://dl.dagger.io/dagger/install.sh | sh; cd -; }
      - name: Run Dagger pipeline
        run: dagger run node index.mjs
        // highlight-start
        env:
           DAGGER_CLOUD_TOKEN: ${{ secrets.DAGGER_CLOUD_TOKEN }}
      # for ephemeral runners only: override the default docker stop timeout and
      # give the Dagger Engine more time to push cache data to Dagger Cloud
      - name: Stop Engine
        run: docker stop -t 300 $(docker ps --filter name="dagger-engine-*" -q)
        if: always()
        // highlight-end
