Fixing github Build-and-push so that it actually pushes #681
Workflow file for this run
This file contains 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 Push | |
on: | |
push: | |
jobs: | |
build_and_push: | |
runs-on: ubuntu-24.04 | |
name: "Build and Push (${{ matrix.services.service_name }})" | |
strategy: | |
fail-fast: true | |
matrix: | |
services: | |
- | |
service_name: app | |
dockerfile: docker-app/Dockerfile | |
docker_context: docker-app | |
docker_target: webserver_runtime | |
enable_dockerhub: true | |
- | |
service_name: app-test | |
dockerfile: docker-app/Dockerfile | |
docker_context: docker-app | |
docker_target: webserver_test | |
enable_dockerhub: false | |
- | |
service_name: worker-wrapper | |
dockerfile: docker-app/Dockerfile | |
docker_context: docker-app | |
docker_target: worker_wrapper_runtime | |
enable_dockerhub: true | |
- | |
service_name: qgis | |
dockerfile: docker-qgis/Dockerfile | |
docker_context: docker-qgis | |
enable_dockerhub: true | |
- | |
service_name: nginx | |
dockerfile: docker-nginx/Dockerfile | |
docker_context: docker-nginx | |
enable_dockerhub: true | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v4 | |
- | |
name: Docker Metadata | |
id: docker_metadata | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
name=ghcr.io/opengisch/qfieldcloud-${{ matrix.services.service_name }},enable=true | |
name=opengisch/qfieldcloud-${{ matrix.services.service_name }},enable=${{ matrix.services.enable_dockerhub && (github.event_name == 'release' || github.ref_name == 'master') }} | |
flavor: | | |
latest=auto | |
prefix=,onlatest=false | |
suffix= | |
tags: | | |
type=ref,enable=true,priority=600,prefix=pr-,suffix=,event=pr | |
type=sha,format=short,prefix=commit-,event=pr | |
type=semver,pattern={{version}},event=release | |
type=edge,branch=main | |
- | |
name: Login to GitHub Container Repository (ghcr.io) | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- | |
name: Login to Docker Hub | |
if: ${{ matrix.services.enable_dockerhub && (github.event_name == 'release' || github.ref_name == 'master') }} | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- | |
name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
- | |
name: Docker Build ${{ matrix.services.service_name }} | |
id: docker_test_application | |
uses: docker/build-push-action@v6 | |
with: | |
file: ${{ matrix.services.dockerfile }} | |
context: ${{ matrix.services.docker_context }} | |
push: ${{ matrix.services.enable_dockerhub && (github.event_name == 'release' || github.ref_name == 'master') }} | |
target: ${{ matrix.services.docker_target }} | |
tags: ${{ steps.docker_metadata.outputs.tags }} | |
cache-from: type=registry,ref=ghcr.io/opengisch/qfieldcloud-${{ matrix.services.service_name }}:buildcache | |
cache-to: type=registry,ref=ghcr.io/opengisch/qfieldcloud-${{ matrix.services.service_name }}:buildcache,mode=max |