Feat/streaming render security #43
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: Docker Multi-Arch Build | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - "feature/**" | |
| tags: | |
| - "v*" | |
| pull_request: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| test-docker: | |
| name: Test Docker Image | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Get package version | |
| id: pkg | |
| run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT | |
| - name: Build image for testing (amd64 only) | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| platforms: linux/amd64 | |
| push: false | |
| load: true | |
| tags: facet:test | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| build-args: | | |
| VERSION=${{ steps.pkg.outputs.version }} | |
| - name: Generate PDF from example template | |
| run: | | |
| mkdir -p /tmp/facet-out | |
| docker run --rm \ | |
| --security-opt seccomp=unconfined \ | |
| -v /tmp/facet-out:/out \ | |
| -w /app/examples \ | |
| facet:test \ | |
| facet pdf SimpleReport.tsx \ | |
| --data simple-data.json \ | |
| --output /out/output.pdf | |
| - name: Verify PDF was created and is non-empty | |
| run: | | |
| if [ ! -f /tmp/facet-out/output.pdf ]; then | |
| echo "ERROR: output.pdf was not created" | |
| exit 1 | |
| fi | |
| SIZE=$(stat -c%s /tmp/facet-out/output.pdf) | |
| echo "output.pdf size: ${SIZE} bytes" | |
| if [ "$SIZE" -lt 1024 ]; then | |
| echo "ERROR: output.pdf is too small (${SIZE} bytes), likely empty or corrupt" | |
| exit 1 | |
| fi | |
| echo "PDF generation successful" | |
| - name: Upload PDF artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-output-pdf | |
| path: /tmp/facet-out/output.pdf | |
| retention-days: 7 | |
| build-and-push: | |
| name: Build and Push Multi-Arch Container | |
| needs: test-docker | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| with: | |
| platforms: all | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| platforms: linux/amd64,linux/arm64 | |
| - name: Log in to Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata (tags, labels) for Docker | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=semver,pattern={{major}} | |
| type=sha | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| - name: Get package version | |
| id: pkg | |
| run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT | |
| - name: Build and push Docker image | |
| id: build | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| platforms: linux/amd64,linux/arm64 | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| build-args: | | |
| BUILDKIT_INLINE_CACHE=1 | |
| VERSION=${{ steps.pkg.outputs.version }} |