diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a4e68ea589c7..37553eb32643 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -112,20 +112,61 @@ jobs: tags: ${{ steps.meta_build_deps.outputs.tags }} labels: ${{ steps.meta_build_deps.outputs.labels }} - #################################################### - # Build/Push the 'dataquest/dspace-dependencies' image + #################################################### + # Build/Push the 'dspace/dspace-dependencies' image. + # This image is used by all other jobs. #################################################### dspace-dependencies: - # Ensure this job never runs on forked repos. It's only executed for 'dataquest/dspace' - if: github.repository == 'dataquest-dev/dspace' - uses: ./.github/workflows/reusable-docker-build.yml - with: - build_id: dspace-dependencies - image_name: dataquest/dspace-dependencies - dockerfile_path: ./Dockerfile.dependencies - secrets: - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - DOCKER_ACCESS_TOKEN: ${{ secrets.DOCKER_ACCESS_TOKEN }} + # Ensure this job never runs on forked repos. It's only executed for 'dspace/dspace' + if: github.repository == 'dspace/dspace' + runs-on: ubuntu-latest + + steps: + # https://github.com/actions/checkout + - name: Checkout codebase + uses: actions/checkout@v3 + + # https://github.com/docker/setup-buildx-action + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v2 + + # https://github.com/docker/setup-qemu-action + - name: Set up QEMU emulation to build for multiple architectures + uses: docker/setup-qemu-action@v2 + + # https://github.com/docker/login-action + - name: Login to DockerHub + # Only login if not a PR, as PRs only trigger a Docker build and not a push + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_ACCESS_TOKEN }} + + # https://github.com/docker/metadata-action + # Get Metadata for docker_build_deps step below + - name: Sync metadata (tags, labels) from GitHub to Docker for 'dspace-dependencies' image + id: meta_build_deps + uses: docker/metadata-action@v4 + with: + images: dspace/dspace-dependencies + tags: ${{ env.IMAGE_TAGS }} + flavor: ${{ env.TAGS_FLAVOR }} + + # https://github.com/docker/build-push-action + - name: Build and push 'dspace-dependencies' image + id: docker_build_deps + uses: docker/build-push-action@v4 + with: + context: . + file: ./Dockerfile.dependencies + platforms: ${{ env.PLATFORMS }} + # For pull requests, we run the Docker build (to ensure no PR changes break the build), + # but we ONLY do an image push to DockerHub if it's NOT a PR + push: ${{ github.event_name != 'pull_request' }} + # Use tags / labels provided by 'docker/metadata-action' above + tags: ${{ steps.meta_build_deps.outputs.tags }} + labels: ${{ steps.meta_build_deps.outputs.labels }} ####################################### # Build/Push the 'dataquest/dspace' image