From 1fc1eeec388f77917408b7ac0ed094d683bc3b96 Mon Sep 17 00:00:00 2001 From: Eugene Brodsky Date: Wed, 7 Dec 2022 08:03:33 -0500 Subject: [PATCH] Fix `docker push` github action and expand with additional metadata (#1837) * update docker build (cloud) action with additional metadata, new labels * (docker) also add aarch64 cloud build and remove arch suffix * (docker) architecture suffix is needed for now * (docker) don't build aarch64 for now --- .github/workflows/build-cloud-img.yml | 47 ++++++++++++++++++++------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-cloud-img.yml b/.github/workflows/build-cloud-img.yml index 94094c9c56..9ef41a26c3 100644 --- a/.github/workflows/build-cloud-img.yml +++ b/.github/workflows/build-cloud-img.yml @@ -4,9 +4,12 @@ on: push: branches: - main - - development tags: - v* + # we will NOT push the image on pull requests, only test buildability. + pull_request: + branches: + - main permissions: contents: read @@ -21,36 +24,56 @@ jobs: strategy: fail-fast: false matrix: - # only x86_64 for now. aarch64+cuda isn't really a thing yet arch: - x86_64 + # requires resolving a patchmatch issue + # - aarch64 runs-on: ubuntu-latest name: ${{ matrix.arch }} steps: - name: Checkout uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + if: matrix.arch == 'aarch64' + - name: Docker meta id: meta uses: docker/metadata-action@v4 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + # see https://github.com/docker/metadata-action + # will push the following tags: + # :edge + # :main (+ any other branches enabled in the workflow) + # : + # :1.2.3 (for semver tags) + # :1.2 (for semver tags) + # : tags: | + type=edge,branch=main type=ref,event=branch type=ref,event=tag - type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} type=sha + # suffix image tags with architecture + flavor: | + latest=auto + suffix=-${{ matrix.arch }},latest=true - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - # - if: github.event_name != 'pull_request' - # name: Docker login - # uses: docker/login-action@v2 - # with: - # registry: ghcr.io - # username: ${{ github.actor }} - # password: ${{ secrets.GITHUB_TOKEN }} + # do not login to container registry on PRs + - if: github.event_name != 'pull_request' + name: Docker login + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push cloud image uses: docker/build-push-action@v3 @@ -58,7 +81,7 @@ jobs: context: . file: docker-build/Dockerfile.cloud platforms: Linux/${{ matrix.arch }} - # push: ${{ github.event_name != 'pull_request' }} - push: false + # do not push the image on PRs + push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }}