Skip to content

Commit 738544f

Browse files
committed
Merge remote-tracking branch 'origin/main' into 22-feature-request-incremental-tts-streaming-with-text-chunking
2 parents 49ded69 + 45088fd commit 738544f

File tree

3 files changed

+126
-5
lines changed

3 files changed

+126
-5
lines changed

.github/workflows/docker-image-pr.yml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,45 @@ name: Docker Image PR Build
22

33
on:
44
pull_request:
5+
types: [opened, synchronize, reopened]
56
branches: [ "main" ]
67

78
jobs:
8-
build:
9+
build-and-push:
10+
# Only run for PRs from the same repository (security measure)
11+
if: github.event.pull_request.head.repo.full_name == github.repository
912
runs-on: ubuntu-latest
1013
permissions:
1114
contents: read
12-
packages: read
15+
packages: write
1316

1417
steps:
1518
- uses: actions/checkout@v4
1619

20+
- name: Set up Docker Buildx
21+
uses: docker/setup-buildx-action@v3
22+
23+
- name: Log in to GitHub Container Registry
24+
uses: docker/login-action@v3
25+
with:
26+
registry: ghcr.io
27+
username: ${{ github.actor }}
28+
password: ${{ secrets.GITHUB_TOKEN }}
29+
1730
- name: Extract metadata (tags, labels) for Docker
1831
id: meta
1932
uses: docker/metadata-action@v5
2033
with:
2134
images: ghcr.io/${{ github.repository }}
2235
tags: |
23-
type=sha
36+
type=raw,value=pr-${{ github.event.number }}
2437
25-
- name: Build Docker image
38+
- name: Build and push Docker image
2639
uses: docker/build-push-action@v5
2740
with:
2841
context: .
29-
push: false
42+
push: true
3043
tags: ${{ steps.meta.outputs.tags }}
3144
labels: ${{ steps.meta.outputs.labels }}
45+
cache-from: type=gha
46+
cache-to: type=gha,mode=max

.github/workflows/pr-cleanup.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: PR Docker Cleanup
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches: [ "main" ]
7+
8+
jobs:
9+
cleanup:
10+
# Only run for PRs from the same repository (security measure)
11+
if: github.event.pull_request.head.repo.full_name == github.repository
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
packages: write
16+
17+
steps:
18+
- name: Log in to GitHub Container Registry
19+
uses: docker/login-action@v3
20+
with:
21+
registry: ghcr.io
22+
username: ${{ github.actor }}
23+
password: ${{ secrets.GITHUB_TOKEN }}
24+
25+
- name: Delete PR Docker image
26+
continue-on-error: true
27+
run: |
28+
# Convert repository name to lowercase for Docker registry
29+
REPO_LOWER=$(echo "${{ github.repository }}" | \
30+
tr '[:upper:]' '[:lower:]')
31+
PACKAGE_NAME=$(basename ${REPO_LOWER})
32+
TAG_NAME="pr-${{ github.event.number }}"
33+
34+
echo "Attempting to delete tag: ${TAG_NAME} for package: ${PACKAGE_NAME}"
35+
36+
# Determine the correct API base path based on repository owner type
37+
OWNER_TYPE="${{ github.repository_owner_type }}"
38+
OWNER="${{ github.repository_owner }}"
39+
if [ "$OWNER_TYPE" = "Organization" ]; then
40+
API_BASE="orgs/${OWNER}"
41+
else
42+
API_BASE="users/${OWNER}"
43+
fi
44+
45+
echo "Using API base path: ${API_BASE}"
46+
47+
# Get all versions of the package with error handling
48+
API_URL="https://api.github.com/${API_BASE}/packages/container/${PACKAGE_NAME}/versions"
49+
RESPONSE=$(curl -sSf \
50+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
51+
-H "Accept: application/vnd.github+json" \
52+
"${API_URL}" 2>&1)
53+
CURL_EXIT_CODE=$?
54+
if [ $CURL_EXIT_CODE -ne 0 ]; then
55+
echo "Error: Failed to fetch package versions from GitHub API. Response:"
56+
echo "$RESPONSE"
57+
exit $CURL_EXIT_CODE
58+
fi
59+
VERSIONS=$(echo "$RESPONSE" | \
60+
jq -r '.[] | select(.metadata.container.tags[]? == "'${TAG_NAME}'") | .id')
61+
62+
if [ -n "$VERSIONS" ]; then
63+
for VERSION_ID in $VERSIONS; do
64+
echo "Deleting version ID: $VERSION_ID with tag: ${TAG_NAME}"
65+
DELETE_URL="${API_URL}/${VERSION_ID}"
66+
DELETE_RESPONSE=$(curl -sSf -X DELETE \
67+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
68+
-H "Accept: application/vnd.github+json" \
69+
"${DELETE_URL}" 2>&1)
70+
DELETE_EXIT_CODE=$?
71+
if [ $DELETE_EXIT_CODE -eq 0 ]; then
72+
echo "Successfully deleted Docker image version: ${VERSION_ID}"
73+
else
74+
echo "Warning: Failed to delete version ID: $VERSION_ID. Response:"
75+
echo "$DELETE_RESPONSE"
76+
fi
77+
done
78+
else
79+
echo "No Docker image found for tag: ${TAG_NAME}, nothing to clean up"
80+
fi

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,32 @@ We follow specific tagging conventions for our Docker images. These tags help in
284284

285285
- **`major.minor version`**: Tags that follow the `major.minor` format (e.g., `0.3`) represent a range of patch-level updates within the same minor version series. These tags are useful for users who want to stay updated with bug fixes and minor improvements without upgrading to a new major or minor version.
286286

287+
- **`pr-{number}`**: Pull request tags (e.g., `pr-123`) are automatically created for each pull request to allow testing of proposed changes before they are merged. These tags are automatically cleaned up when the pull request is closed or merged.
288+
289+
#### 9. Pull Request Docker Images
290+
291+
For contributors and maintainers who want to test changes from pull requests before they are merged, we automatically build and push Docker images for each pull request.
292+
293+
**How it works:**
294+
- When a pull request is opened or updated, a Docker image is automatically built and pushed with the tag `pr-{pr_number}`
295+
- Only pull requests from the main repository (not forks) will trigger image builds for security reasons
296+
- When a pull request is closed or merged, the corresponding Docker image is automatically deleted to save storage space
297+
298+
**Using PR images:**
299+
```bash
300+
# Example: Test PR #123
301+
docker run --rm -p 10300:10300 ghcr.io/roryeckel/wyoming_openai:pr-123
302+
303+
# Or with docker-compose, update your docker-compose.yml:
304+
# image: ghcr.io/roryeckel/wyoming_openai:pr-123
305+
```
306+
307+
**For contributors:**
308+
- PR images are built automatically - no action needed
309+
- Images are available within minutes of opening/updating a PR
310+
- Check the Actions tab to see build status
311+
- Images are automatically cleaned up when the PR is closed
312+
287313
### General Deployment Steps
288314

289315
1. **Start Services**: Run the appropriate Docker Compose command based on your deployment option.

0 commit comments

Comments
 (0)