-
Notifications
You must be signed in to change notification settings - Fork 59
149 lines (123 loc) · 4.33 KB
/
Copy pathdocker-build.yml
File metadata and controls
149 lines (123 loc) · 4.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: Build and Push Docker Image
on:
workflow_dispatch:
inputs:
version:
description: 'Version tag for the Docker image'
required: true
type: string
default: 'latest'
pull_request:
push:
branches:
- main
- runpod-serverless
tags:
- 'v*'
# Permissions for the reusable workflow jobs
permissions:
contents: read
packages: write
pull-requests: write
issues: write
jobs:
# Cloud image - faster, used for PR deploys
build-cloud:
uses: ./.github/workflows/docker-build-image.yml
with:
variant: cloud
suffix: '-cloud'
dockerfile: Dockerfile.cloud
description: Daydream Scope (Cloud)
secrets: inherit
# Standard image - slower, not needed for PR deploys
build-standard:
uses: ./.github/workflows/docker-build-image.yml
with:
variant: standard
suffix: ''
dockerfile: Dockerfile
description: Daydream Scope
secrets: inherit
# PR deploy - only waits for cloud build
deploy-pr:
needs: build-cloud
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
outputs:
livepeer_fal_app_id: ${{ steps.deploy_livepeer.outputs.livepeer_fal_app_id }}
livepeer_fal_ws_url: ${{ steps.deploy_livepeer.outputs.livepeer_fal_ws_url }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install fal
run: pip install fal
- name: Deploy Livepeer runner to fal (PR environment)
id: deploy_livepeer
env:
FAL_KEY: ${{ secrets.FAL_KEY }}
run: |
set -euo pipefail
PR_NUMBER="${{ needs.build-cloud.outputs.pr_number }}"
APP_NAME="scope-livepeer-pr-${PR_NUMBER}"
echo "Deploying Livepeer runner for PR #${PR_NUMBER} to fal as ${APP_NAME}"
fal deploy \
--app-name "$APP_NAME" \
--env preview \
--auth private \
src/scope/cloud/livepeer_fal_app.py 2>&1 | tee deploy_livepeer_output.txt
LIVEPEER_FAL_APP_ID="daydream/${APP_NAME}--preview"
LIVEPEER_FAL_WS_URL="wss://fal.run/${LIVEPEER_FAL_APP_ID}/ws"
echo "livepeer_fal_app_id=${LIVEPEER_FAL_APP_ID}" >> $GITHUB_OUTPUT
echo "livepeer_fal_ws_url=${LIVEPEER_FAL_WS_URL}" >> $GITHUB_OUTPUT
echo "Deployed Livepeer runner to: ${LIVEPEER_FAL_APP_ID}"
echo "Livepeer WebSocket URL: ${LIVEPEER_FAL_WS_URL}"
- name: Comment on PR with deployment info
uses: actions/github-script@v7
with:
script: |
const prNumber = ${{ github.event.pull_request.number }};
const livepeerFalAppId = '${{ steps.deploy_livepeer.outputs.livepeer_fal_app_id }}';
const livepeerFalWsUrl = '${{ steps.deploy_livepeer.outputs.livepeer_fal_ws_url }}';
const shortSha = '${{ needs.build-cloud.outputs.short_sha }}';
const body = `## 🚀 fal.ai Preview Deployment
| | |
|---|---|
| **Commit** | \`${shortSha}\` |
| **App ID** | \`${livepeerFalAppId}\` |
| **WebSocket** | \`${livepeerFalWsUrl}\` |
### Testing on Cloud
\`\`\`
SCOPE_CLOUD_APP_ID="${livepeerFalAppId}/ws" uv run daydream-scope
\`\`\`
`;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber
});
const existingComment = comments.find(c =>
c.user.type === 'Bot' &&
c.body.includes('fal.ai Preview Deployment')
);
if (existingComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existingComment.id,
body
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body
});
}