diff --git a/.github/workflows/cloud-preview.yml b/.github/workflows/cloud-preview.yml new file mode 100644 index 00000000..5b43c26b --- /dev/null +++ b/.github/workflows/cloud-preview.yml @@ -0,0 +1,67 @@ +name: Cloud Preview + +on: + pull_request: + types: [opened, synchronize, reopened, closed] + +jobs: + dispatch-deploy: + name: Trigger Cloud Preview + if: github.event.action != 'closed' + runs-on: ubuntu-latest + steps: + - name: Generate GitHub App Token + id: generate_token + uses: tibdex/github-app-token@v1 + with: + app_id: ${{ secrets.GH_APP_PUSHER_ID }} + private_key: ${{ secrets.GH_APP_PUSHER_PRIVATE_KEY }} + + - name: Dispatch preview deploy + uses: actions/github-script@v7 + with: + github-token: ${{ steps.generate_token.outputs.token }} + script: | + await github.rest.actions.createWorkflowDispatch({ + owner: 'AgentWorkforce', + repo: 'cloud', + workflow_id: 'preview-relayfile.yml', + ref: 'main', + inputs: { + pr_number: String(context.payload.pull_request.number), + head_sha: context.payload.pull_request.head.sha, + sdk_ref: context.payload.pull_request.head.ref, + source_repo: context.payload.repository.full_name, + action: 'deploy', + }, + }); + + dispatch-cleanup: + name: Cleanup Cloud Preview + if: github.event.action == 'closed' + runs-on: ubuntu-latest + steps: + - name: Generate GitHub App Token + id: generate_token + uses: tibdex/github-app-token@v1 + with: + app_id: ${{ secrets.GH_APP_PUSHER_ID }} + private_key: ${{ secrets.GH_APP_PUSHER_PRIVATE_KEY }} + + - name: Dispatch preview cleanup + uses: actions/github-script@v7 + with: + github-token: ${{ steps.generate_token.outputs.token }} + script: | + await github.rest.actions.createWorkflowDispatch({ + owner: 'AgentWorkforce', + repo: 'cloud', + workflow_id: 'preview-relayfile.yml', + ref: 'main', + inputs: { + pr_number: String(context.payload.pull_request.number), + head_sha: context.payload.pull_request.head.sha, + source_repo: context.payload.repository.full_name, + action: 'cleanup', + }, + });