Build and Publish Docker Image #15
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 | |
| permissions: | |
| contents: read | |
| packages: write | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| schedule: | |
| - cron: 43 2 * * 0 | |
| jobs: | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: docker/setup-qemu-action@v3 | |
| - uses: docker/setup-buildx-action@v3 | |
| - uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build initial image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| load: true | |
| tags: build-chromium | |
| - name: Determine version of Chromium obtained | |
| env: | |
| CHROMIUM_VERSION_REGEXP: 'Chromium ([0-9]+)\.' | |
| run: | | |
| CURRENT_CHROMIUM_VERSION=$(docker container run --rm build-chromium --version) | |
| if [[ ${CURRENT_CHROMIUM_VERSION} =~ ${CHROMIUM_VERSION_REGEXP} ]]; then | |
| echo "ℹ Successfully extracted Chromium major version of ${BASH_REMATCH[1]} from '${CURRENT_CHROMIUM_VERSION}'" | |
| else | |
| echo "❌ Cannot extract Chromium major version from '${CURRENT_CHROMIUM_VERSION}'" >&2 | |
| exit 1 | |
| fi | |
| echo "CHROMIUM_VERSION=${BASH_REMATCH[1]}" >> $GITHUB_ENV | |
| - name: Build cross-platform images and push to registry | |
| if: github.event_name != 'pull_request' | |
| uses: docker/build-push-action@v6 | |
| with: | |
| platforms: linux/amd64,linux/arm64 | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| push: true | |
| tags: | | |
| ghcr.io/webfactory/alpine-chromium:latest | |
| ghcr.io/webfactory/alpine-chromium:${{ env.CHROMIUM_VERSION }} | |
| labels: org.opencontainers.image.source=https://github.com/webfactory/docker-alpine-chromium | |
| env: | |
| DOCKER_BUILD_SUMMARY: false | |
| DOCKER_BUILD_RECORD_UPLOAD: false |