mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-11-25 00:19:22 +09:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6e8997eae8 | ||
|
|
3ba3dc2d02 | ||
|
|
257f592ef7 | ||
|
|
9a33b6a6e0 | ||
|
|
4508c27ade | ||
|
|
8e3bd636c4 |
No files matched your search
@@ -638,14 +638,10 @@ jobs:
|
||||
BASE_IMAGE_NAME: karaoke-backend-base
|
||||
APP_IMAGE_NAME: karaoke-backend
|
||||
steps:
|
||||
# ============================================
|
||||
# Check if deployment is needed FIRST
|
||||
# ============================================
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: false
|
||||
fetch-depth: 0 # Need full history for tag check
|
||||
|
||||
- name: Set up Python 3.13
|
||||
uses: actions/setup-python@v5
|
||||
@@ -655,26 +651,15 @@ jobs:
|
||||
- name: Install Poetry
|
||||
uses: snok/install-poetry@v1
|
||||
|
||||
- name: Extract version and check if deployment needed
|
||||
- name: Extract version
|
||||
id: version_check
|
||||
run: |
|
||||
VERSION=$(poetry version --short)
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
echo "📋 Current version: $VERSION"
|
||||
|
||||
if git ls-remote --tags origin | grep -q "refs/tags/v$VERSION$"; then
|
||||
echo "needs_deploy=false" >> $GITHUB_OUTPUT
|
||||
echo "⏭️ Tag v$VERSION already exists - skipping backend deployment"
|
||||
echo " (Bump version in pyproject.toml to trigger a new deployment)"
|
||||
else
|
||||
echo "needs_deploy=true" >> $GITHUB_OUTPUT
|
||||
echo "✨ Tag v$VERSION does not exist - proceeding with deployment"
|
||||
fi
|
||||
|
||||
# No disk cleanup needed - self-hosted runner has 200GB SSD
|
||||
echo "🚀 Deploying on every push to main"
|
||||
|
||||
- name: Authenticate to Google Cloud (Workload Identity)
|
||||
if: steps.version_check.outputs.needs_deploy == 'true'
|
||||
id: auth
|
||||
uses: google-github-actions/auth@v2
|
||||
with:
|
||||
@@ -682,13 +667,11 @@ jobs:
|
||||
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
|
||||
|
||||
- name: Set up Cloud SDK
|
||||
if: steps.version_check.outputs.needs_deploy == 'true'
|
||||
uses: google-github-actions/setup-gcloud@v2
|
||||
with:
|
||||
version: "latest"
|
||||
|
||||
- name: Configure Docker for Artifact Registry
|
||||
if: steps.version_check.outputs.needs_deploy == 'true'
|
||||
run: gcloud auth configure-docker ${{ env.REGISTRY }} --quiet
|
||||
|
||||
# ============================================
|
||||
@@ -698,11 +681,9 @@ jobs:
|
||||
# ============================================
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
if: steps.version_check.outputs.needs_deploy == 'true'
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Calculate base image hash
|
||||
if: steps.version_check.outputs.needs_deploy == 'true'
|
||||
id: base-hash
|
||||
run: |
|
||||
# Hash both poetry.lock AND Dockerfile.base - rebuild if either changes
|
||||
@@ -711,7 +692,6 @@ jobs:
|
||||
echo "📋 Base content hash: $CURRENT_HASH"
|
||||
|
||||
- name: Check if base image exists and is current
|
||||
if: steps.version_check.outputs.needs_deploy == 'true'
|
||||
id: check-base
|
||||
run: |
|
||||
BASE_IMAGE="${{ env.REGISTRY }}/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.BASE_IMAGE_NAME }}:latest"
|
||||
@@ -738,7 +718,7 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: Build and push base image (if needed)
|
||||
if: steps.version_check.outputs.needs_deploy == 'true' && steps.check-base.outputs.needs_rebuild == 'true'
|
||||
if: steps.check-base.outputs.needs_rebuild == 'true'
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
@@ -759,7 +739,6 @@ jobs:
|
||||
provenance: false
|
||||
|
||||
- name: Build and push app image
|
||||
if: steps.version_check.outputs.needs_deploy == 'true'
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
@@ -780,7 +759,6 @@ jobs:
|
||||
# ============================================
|
||||
|
||||
- name: Deploy to Cloud Run
|
||||
if: steps.version_check.outputs.needs_deploy == 'true'
|
||||
run: |
|
||||
VERSION="${{ steps.version_check.outputs.version }}"
|
||||
IMAGE="${{ env.REGISTRY }}/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.APP_IMAGE_NAME }}:${{ github.sha }}"
|
||||
@@ -806,7 +784,6 @@ jobs:
|
||||
--set-secrets "AUDIOSHAKE_API_TOKEN=audioshake-api-key:latest,GENIUS_API_TOKEN=genius-api-key:latest,SPOTIFY_COOKIE_SP_DC=spotify-cookie:latest,RAPIDAPI_KEY=rapidapi-key:latest,DEFAULT_DISCORD_WEBHOOK_URL=discord-releases-webhook:latest,ADMIN_TOKENS=admin-tokens:latest,RED_API_KEY=red-api-key:latest,RED_API_URL=red-api-url:latest,OPS_API_KEY=ops-api-key:latest,OPS_API_URL=ops-api-url:latest,FLACFETCH_API_URL=flacfetch-api-url:latest,FLACFETCH_API_KEY=flacfetch-api-key:latest"
|
||||
|
||||
- name: Verify deployment and version
|
||||
if: steps.version_check.outputs.needs_deploy == 'true'
|
||||
run: |
|
||||
EXPECTED_VERSION="${{ steps.version_check.outputs.version }}"
|
||||
SERVICE_URL=$(gcloud run services describe karaoke-backend \
|
||||
@@ -847,7 +824,7 @@ jobs:
|
||||
done
|
||||
|
||||
- name: Summary
|
||||
if: steps.version_check.outputs.needs_deploy == 'true' && success()
|
||||
if: success()
|
||||
run: |
|
||||
echo "🎉 Deployment successful!"
|
||||
echo "Version: ${{ steps.version_check.outputs.version }}"
|
||||
@@ -857,12 +834,3 @@ jobs:
|
||||
echo ""
|
||||
echo "📊 Built on self-hosted GCP runner (200GB SSD, no disk space issues)"
|
||||
echo " Runner: gcp-runner with 4 vCPU, 16GB RAM"
|
||||
|
||||
- name: Skipped deployment summary
|
||||
if: steps.version_check.outputs.needs_deploy == 'false'
|
||||
run: |
|
||||
echo "⏭️ Backend deployment skipped - version ${{ steps.version_check.outputs.version }} already deployed"
|
||||
echo ""
|
||||
echo "To deploy a new version:"
|
||||
echo " 1. Update version in pyproject.toml"
|
||||
echo " 2. Commit and push to main"
|
||||
@@ -30,8 +30,8 @@ export function OutputLinks({ jobId }: OutputLinksProps) {
|
||||
if (job.state_data?.youtube_url) {
|
||||
setYoutubeUrl(job.state_data.youtube_url)
|
||||
}
|
||||
if (job.state_data?.dropbox_folder_url) {
|
||||
setDropboxUrl(job.state_data.dropbox_folder_url)
|
||||
if (job.state_data?.dropbox_link) {
|
||||
setDropboxUrl(job.state_data.dropbox_link)
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Failed to load output links:", err)
|
||||
@@ -49,13 +49,16 @@ export function OutputLinks({ jobId }: OutputLinksProps) {
|
||||
)
|
||||
}
|
||||
|
||||
const hasOutputs = youtubeUrl || dropboxUrl || (downloadUrls && Object.keys(downloadUrls).length > 0)
|
||||
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
{/* Distribution Links */}
|
||||
{(youtubeUrl || dropboxUrl) && (
|
||||
{/* Combined Output Links */}
|
||||
{hasOutputs && (
|
||||
<div className="space-y-2">
|
||||
<p className="text-xs text-slate-400 font-medium">Distribution:</p>
|
||||
<p className="text-xs text-slate-400 font-medium">Outputs:</p>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{/* Distribution Links */}
|
||||
{youtubeUrl && (
|
||||
<a
|
||||
href={youtubeUrl}
|
||||
@@ -77,19 +80,11 @@ export function OutputLinks({ jobId }: OutputLinksProps) {
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<FolderOpen className="w-3 h-3" />
|
||||
Open Dropbox Folder
|
||||
Dropbox Folder
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Download Links */}
|
||||
{downloadUrls && Object.keys(downloadUrls).length > 0 && (
|
||||
<div className="space-y-2">
|
||||
<p className="text-xs text-slate-400 font-medium">Downloads:</p>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{downloadUrls.finals?.lossy_720p && (
|
||||
{/* Download Links */}
|
||||
{downloadUrls?.finals?.lossy_720p && (
|
||||
<a
|
||||
href={api.getDownloadUrl(jobId, "finals", "lossy_720p")}
|
||||
className="inline-flex items-center gap-1 text-xs px-3 py-1.5 rounded bg-green-600 hover:bg-green-500 text-white"
|
||||
@@ -99,7 +94,7 @@ export function OutputLinks({ jobId }: OutputLinksProps) {
|
||||
720p Video
|
||||
</a>
|
||||
)}
|
||||
{downloadUrls.finals?.lossy_4k_mp4 && (
|
||||
{downloadUrls?.finals?.lossy_4k_mp4 && (
|
||||
<a
|
||||
href={api.getDownloadUrl(jobId, "finals", "lossy_4k_mp4")}
|
||||
className="inline-flex items-center gap-1 text-xs px-3 py-1.5 rounded bg-green-600 hover:bg-green-500 text-white"
|
||||
@@ -109,7 +104,7 @@ export function OutputLinks({ jobId }: OutputLinksProps) {
|
||||
4K Video
|
||||
</a>
|
||||
)}
|
||||
{downloadUrls.packages?.cdg_zip && (
|
||||
{downloadUrls?.packages?.cdg_zip && (
|
||||
<a
|
||||
href={api.getDownloadUrl(jobId, "packages", "cdg_zip")}
|
||||
className="inline-flex items-center gap-1 text-xs px-2 py-1.5 rounded bg-slate-600 hover:bg-slate-500 text-white"
|
||||
@@ -119,7 +114,7 @@ export function OutputLinks({ jobId }: OutputLinksProps) {
|
||||
CDG+MP3
|
||||
</a>
|
||||
)}
|
||||
{downloadUrls.packages?.txt_zip && (
|
||||
{downloadUrls?.packages?.txt_zip && (
|
||||
<a
|
||||
href={api.getDownloadUrl(jobId, "packages", "txt_zip")}
|
||||
className="inline-flex items-center gap-1 text-xs px-2 py-1.5 rounded bg-slate-600 hover:bg-slate-500 text-white"
|
||||
@@ -133,7 +128,7 @@ export function OutputLinks({ jobId }: OutputLinksProps) {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!downloadUrls && !youtubeUrl && !dropboxUrl && (
|
||||
{!hasOutputs && (
|
||||
<p className="text-xs text-slate-500">No outputs available yet</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Generated
+57
-810
File diff suppressed because it is too large.
Load diff
@@ -82,8 +82,8 @@
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.57.0",
|
||||
"@tailwindcss/postcss": "^4.1.9",
|
||||
"@testing-library/jest-dom": "^6.1.5",
|
||||
"@testing-library/react": "^14.1.2",
|
||||
"@testing-library/jest-dom": "^6.9.1",
|
||||
"@testing-library/react": "^16.3.1",
|
||||
"@testing-library/user-event": "^14.5.1",
|
||||
"@types/jest": "^29.5.11",
|
||||
"@types/node": "^22",
|
||||
|
||||
@@ -262,7 +262,7 @@ Multiple GCP VMs run self-hosted GitHub Actions runners to:
|
||||
|
||||
### Specs
|
||||
|
||||
- **Instances**: 5x e2-standard-4 (4 vCPU, 16GB RAM each)
|
||||
- **Instances**: 10x e2-standard-4 (4 vCPU, 16GB RAM each)
|
||||
- **Disk**: 200GB SSD per runner
|
||||
- **Pre-installed**: Docker, Python 3.13, Node.js 20, Java 21, Poetry, FFmpeg, gcloud CLI
|
||||
- **Labels**: `self-hosted`, `linux`, `x64`, `gcp`, `large-disk`
|
||||
@@ -285,7 +285,7 @@ Multiple GCP VMs run self-hosted GitHub Actions runners to:
|
||||
|
||||
4. Verify the runners registered:
|
||||
- Go to https://github.com/nomadkaraoke/karaoke-gen/settings/actions/runners
|
||||
- You should see `gcp-runner-github-runner-1` through `gcp-runner-github-runner-5`
|
||||
- You should see `gcp-runner-github-runner-1` through `gcp-runner-github-runner-10`
|
||||
|
||||
### Usage in Workflows
|
||||
|
||||
@@ -306,7 +306,7 @@ GitHub automatically distributes jobs across available runners.
|
||||
|
||||
**Runner not appearing in GitHub:**
|
||||
```bash
|
||||
# Check startup logs (replace N with runner number 1-3)
|
||||
# Check startup logs (replace N with runner number 1-10)
|
||||
gcloud compute ssh github-runner-N --zone=us-central1-a -- \
|
||||
"sudo cat /var/log/github-runner-startup.log"
|
||||
```
|
||||
@@ -325,7 +325,7 @@ gcloud compute ssh github-runner-N --zone=us-central1-a -- \
|
||||
|
||||
**List all runners:**
|
||||
```bash
|
||||
for i in 1 2 3 4 5; do
|
||||
for i in {1..10}; do
|
||||
echo "=== github-runner-$i ==="
|
||||
gcloud compute instances describe github-runner-$i --zone=us-central1-a --format='get(status)'
|
||||
done
|
||||
|
||||
@@ -1419,7 +1419,7 @@ echo "Setup complete!"
|
||||
"""
|
||||
|
||||
# GitHub runner VM instances (multiple runners for parallel job execution)
|
||||
NUM_RUNNERS = 5
|
||||
NUM_RUNNERS = 10
|
||||
github_runner_vms = []
|
||||
|
||||
for i in range(1, NUM_RUNNERS + 1):
|
||||
@@ -1447,7 +1447,11 @@ for i in range(1, NUM_RUNNERS + 1):
|
||||
tags=["github-runner"],
|
||||
allow_stopping_for_update=True,
|
||||
# Ensure the secret exists before creating the VM
|
||||
opts=pulumi.ResourceOptions(depends_on=[github_runner_pat_secret]),
|
||||
# For existing runners (1-5), ignore startup script changes to avoid replacement
|
||||
opts=pulumi.ResourceOptions(
|
||||
depends_on=[github_runner_pat_secret],
|
||||
ignore_changes=["metadataStartupScript"] if i <= 5 else None,
|
||||
),
|
||||
)
|
||||
github_runner_vms.append(vm)
|
||||
|
||||
|
||||
Reference in new issue
Block a user