name: 'Preview Environment Dispatch' permissions: contents: write on: pull_request_target: types: [opened, synchronize, reopened, labeled] paths: - packages/twenty-docker/** - packages/twenty-server/** - packages/twenty-front/** - .github/workflows/preview-env-dispatch.yaml - .github/workflows/preview-env-keepalive.yaml concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: trigger-preview: if: | (github.event.action == 'labeled' && github.event.label.name == 'preview-app') || ( ( github.event.pull_request.author_association == 'MEMBER' || github.event.pull_request.author_association == 'OWNER' || github.event.pull_request.author_association == 'COLLABORATOR' ) && ( github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.action == 'reopened' ) ) timeout-minutes: 5 runs-on: ubuntu-latest steps: - name: Trigger preview environment workflow uses: peter-evans/repository-dispatch@v2 with: token: ${{ secrets.GITHUB_TOKEN }} repository: ${{ github.repository }} event-type: preview-environment client-payload: '{"pr_number": "${{ github.event.pull_request.number }}", "pr_head_sha": "${{ github.event.pull_request.head.sha }}", "repo_full_name": "${{ github.repository }}"}' - name: Dispatch to ci-privileged for PR comment uses: peter-evans/repository-dispatch@v2 with: token: ${{ secrets.CI_PRIVILEGED_DISPATCH_TOKEN }} repository: twentyhq/ci-privileged event-type: preview-env-url client-payload: '{"pr_number": ${{ toJSON(github.event.pull_request.number) }}, "keepalive_dispatch_time": ${{ toJSON(github.event.pull_request.updated_at) }}, "repo": ${{ toJSON(github.repository) }}}'