Sandbox Image #2
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: Sandbox Image | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| image: | |
| description: 'Fully qualified image name to push (registry/namespace/name)' | |
| required: false | |
| default: 'docker.io/cstechdev/ocm-sandbox' | |
| playwright_version: | |
| description: 'Playwright version providing the bundled Chromium' | |
| required: false | |
| default: '1.56.0' | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Resolve build inputs | |
| id: resolve | |
| env: | |
| REGISTRY_USERNAME: ${{ secrets.SANDBOX_REGISTRY_USERNAME }} | |
| REGISTRY_TOKEN: ${{ secrets.SANDBOX_REGISTRY_TOKEN }} | |
| run: | | |
| IMAGE="${{ github.event.inputs.image }}" | |
| [ -n "$IMAGE" ] || IMAGE="docker.io/cstechdev/ocm-sandbox" | |
| PLAYWRIGHT_VERSION="${{ github.event.inputs.playwright_version }}" | |
| [ -n "$PLAYWRIGHT_VERSION" ] || PLAYWRIGHT_VERSION="1.56.0" | |
| REGISTRY="${IMAGE%%/*}" | |
| case "$REGISTRY" in | |
| *.*|*:*|localhost) ;; | |
| *) echo "ERROR: image '$IMAGE' must be fully qualified with a registry host" >&2; exit 1 ;; | |
| esac | |
| if [ "$REGISTRY" != "ghcr.io" ] && { [ -z "$REGISTRY_USERNAME" ] || [ -z "$REGISTRY_TOKEN" ]; }; then | |
| echo "ERROR: pushing to $REGISTRY requires the SANDBOX_REGISTRY_USERNAME and SANDBOX_REGISTRY_TOKEN repository secrets" >&2 | |
| echo "GITHUB_TOKEN only authenticates against ghcr.io" >&2 | |
| exit 1 | |
| fi | |
| echo "image=${IMAGE}" >> $GITHUB_OUTPUT | |
| echo "registry=${REGISTRY}" >> $GITHUB_OUTPUT | |
| echo "playwright=${PLAYWRIGHT_VERSION}" >> $GITHUB_OUTPUT | |
| echo "Building ${IMAGE} on ${REGISTRY} with playwright=${PLAYWRIGHT_VERSION}" | |
| - name: Docker meta | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ steps.resolve.outputs.image }} | |
| tags: | | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=semver,pattern={{major}} | |
| type=raw,value=latest | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ steps.resolve.outputs.registry }} | |
| username: ${{ secrets.SANDBOX_REGISTRY_USERNAME || github.actor }} | |
| password: ${{ secrets.SANDBOX_REGISTRY_TOKEN || secrets.GITHUB_TOKEN }} | |
| - name: Build and push | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: Dockerfile.sandbox | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| build-args: | | |
| PLAYWRIGHT_VERSION=${{ steps.resolve.outputs.playwright }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Report digest | |
| run: echo "Published ${{ steps.meta.outputs.tags }}" |