Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 29 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,43 +24,59 @@ jobs:
- name: Checkout Code
uses: actions/checkout@v4

# 2. Log in to GitHub Container Registry
# Setup Docker Buildx to enable advanced build features and caching
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# Build and cache Docker layers using GitHub Actions cache backend
# 'load: true' exports the image to the local Docker daemon for testing
- name: Build and Load Docker Image
uses: docker/build-push-action@v5
with:
context: .
load: true
tags: worker-ffmpeg:latest
cache-from: type=gha
cache-to: type=gha,mode=max

# Authenticate to GHCR for image publishing
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
password: ${{ secrets.GITHUB_TOKEN }}

# 3. Download a sample test video (1080p, ~2MB)
# Dynamically to keep the git repo small.
# The script expects 'video', so we simulate that structure.
# Fetch reference test asset (1080p H.264)
# Dynamic download avoids repository bloat
- name: Download Test Asset
run: |
mkdir -p video
echo "Downloading sample video..."
# Using a reliable test video source (Big Buck Bunny stable link)
# Source: Big Buck Bunny (Stable URL)
curl -L -o video/test.mp4 https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/1080/Big_Buck_Bunny_1080_10s_5MB.mp4
ls -lh video/

# 4. Run the Test Script
# Since ffmpeg.test.sh handles 'docker build', we just run it directly.
# Execute integration test suite
# Patch script to skip redundant build step (using cached image)
- name: Run Test Suite
env:
SKIP_BUILD: 'true'
run: |
chmod +x test/ffmpeg.test.sh
bash test/ffmpeg.test.sh

# 5. Push Image to GHCR (Only on Main)
# Publish artifact to GHCR (Production branch only)
- name: Push to GHCR
if: github.ref == 'refs/heads/main'
run: |
IMAGE_ID=ghcr.io/${{ github.repository }}
# Change all uppercase to lowercase
# Normalize repository name to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')

# Tag the image built by ffmpeg.test.sh with the proper GHCR name
docker tag worker-ffmpeg $IMAGE_ID:latest
docker tag worker-ffmpeg $IMAGE_ID:${{ github.sha }}
# Apply semantic tags (latest, SHA) for versioning
docker tag worker-ffmpeg:latest $IMAGE_ID:latest
docker tag worker-ffmpeg:latest $IMAGE_ID:${{ github.sha }}

echo "Pushing $IMAGE_ID:latest"
docker push $IMAGE_ID:latest
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "worker",
"version": "0.0.0",
"version": "0.1.0",
"description": "FFmpeg worker",
"repository": {
"type": "git",
Expand Down
8 changes: 7 additions & 1 deletion test/ffmpeg.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,13 @@ print_stats() {
# Main Execution
main() {
check_prerequisites
build_image

if [[ "${SKIP_BUILD:-false}" != "true" ]]; then
build_image
else
log_info "Skipping build step (SKIP_BUILD=true)..."
fi

verify_ffmpeg_version
verify_ffprobe_version
verify_codecs
Expand Down