Skip to content
66 changes: 66 additions & 0 deletions .github/workflows/cloud-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
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-relayauth.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: '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-relayauth.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',
},
});
Loading