feat: add template parameter and configurable write timeout #106
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Publish Docker Image | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| branches: | |
| - main | |
| env: | |
| REGISTRY: ghcr.io | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| - name: Set image name to lowercase | |
| id: image | |
| run: echo "name=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GitHub Container Registry | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata (tags, labels) | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ steps.image.outputs.name }} | |
| tags: | | |
| # Tag with version on release tags (v1.0.0 -> 1.0.0) | |
| type=semver,pattern={{version}} | |
| # Tag with major.minor on release tags (v1.0.0 -> 1.0) | |
| type=semver,pattern={{major}}.{{minor}} | |
| # Tag with major on release tags (v1.0.0 -> 1) | |
| type=semver,pattern={{major}} | |
| # Tag with 'latest' on main branch | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| # Tag with branch name | |
| type=ref,event=branch | |
| # Tag with PR number for PRs | |
| type=ref,event=pr | |
| # Tag with commit SHA (short form) | |
| type=sha,format=short | |
| - name: Build Docker image (amd64 for testing) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: false | |
| platforms: linux/amd64 | |
| tags: ${{ env.REGISTRY }}/${{ steps.image.outputs.name }}:test | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| load: true | |
| - name: Test Docker image | |
| run: | | |
| # Start container in background | |
| docker run -d --name test-container \ | |
| -p 3000:3000 \ | |
| -e OUTLINE_API_KEY=test-key \ | |
| -e OUTLINE_API_URL=http://localhost:3030/api \ | |
| ${{ env.REGISTRY }}/${{ steps.image.outputs.name }}:test | |
| # Wait for container to be healthy (max 30 seconds) | |
| # Note: /health checks server is running, /ready checks Outline connectivity | |
| echo "Waiting for container to be healthy..." | |
| for i in {1..30}; do | |
| if curl -sf http://localhost:3000/health > /dev/null 2>&1; then | |
| echo "✅ Container is healthy" | |
| break | |
| fi | |
| if [ $i -eq 30 ]; then | |
| echo "❌ Container failed to become healthy" | |
| docker logs test-container | |
| exit 1 | |
| fi | |
| sleep 1 | |
| done | |
| # Cleanup | |
| docker stop test-container | |
| docker rm test-container | |
| - name: Build Docker image (multi-arch validation) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: false | |
| platforms: linux/amd64,linux/arm64 | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Push Docker image to registry | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: true | |
| platforms: linux/amd64,linux/arm64 | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Image published | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| run: | | |
| echo "✅ Docker image published to ${{ env.REGISTRY }}/${{ steps.image.outputs.name }}" | |
| echo "📦 Tags: ${{ steps.meta.outputs.tags }}" | |
| echo "" | |
| echo "To use this image:" | |
| echo " docker pull ${{ env.REGISTRY }}/${{ steps.image.outputs.name }}:${{ steps.meta.outputs.version }}" |