Skip to content

Commit

Permalink
Bring Docker image publishing in line with Saleor Core (#5101)
Browse files Browse the repository at this point in the history
* Bring Docker image publishing in line with Saleor Core

This will automatically tag images with with both the full version and just the minor (e.g., "3.20").

It may change the reported version strings for untagged releases so please review if the behavior of `PROJECT_VERSION` is acceptable.

* Create giant-colts-pump.md

---------

Co-authored-by: Patryk Andrzejewski <vox3r69@gmail.com>
Co-authored-by: Paweł Chyła <chyla1988@gmail.com>
  • Loading branch information
3 people authored and Cloud11PL committed Sep 4, 2024
1 parent 850997c commit bef2cbd
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 35 deletions.
5 changes: 5 additions & 0 deletions .changeset/giant-colts-pump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

Docker images will be automatically tag with with both the full version and just the minor
62 changes: 27 additions & 35 deletions .github/workflows/publish-containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,75 +7,67 @@ on:
jobs:
docker:
runs-on: ubuntu-20.04

permissions:
contents: read
packages: write

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

# Outputs the name of the repository (owner/repo)
- name: Get image name
- name: Build Image Name
id: image
run: |
IMAGE_NAME=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')
echo "image_name=ghcr.io/${IMAGE_NAME}" >> $GITHUB_OUTPUT
# Tags stable versions as :latest
# Pre-releases, alphas, etc. as :snapshot
- name: Output image tags from git tag events
if: ${{ startsWith(github.ref, 'refs/tags/') }}
env:
GH_TOKEN: ${{ github.token }}
run: |
LATEST_VERSION=$(gh api repos/saleor/saleor-dashboard/releases/latest | jq -r .tag_name)
CURRENT_TAG=${GITHUB_REF#refs/tags/}
echo "image_name=$IMAGE_NAME" >> $GITHUB_OUTPUT
if [ "$LATEST_VERSION" = "$CURRENT_TAG" ]; then
TAGS=${{ steps.image.outputs.image_name }}:${CURRENT_TAG},${{ steps.image.outputs.image_name }}:latest
else
TAGS=${{ steps.image.outputs.image_name }}:${CURRENT_TAG}
fi
echo "
DASHBOARD_VERSION=${CURRENT_TAG}
CONTAINER_TAGS=${TAGS}
" >> "${GITHUB_ENV}"
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ steps.image.outputs.image_name }}
tags: |
type=ref,event=branch
type=pep440,pattern={{version}}
type=pep440,pattern={{major}}.{{minor}}
- name: Set up Docker QEMU
uses: docker/setup-qemu-action@v1
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push
id: docker_build
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.CONTAINER_TAGS }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
tags: ${{ steps.meta.outputs.tags }}
build-args: |
COMMIT_ID=${{ github.sha }}
PROJECT_VERSION=$DASHBOARD_VERSION
PROJECT_VERSION=${{ steps.meta.outputs.version }}
- name: Output image digest
- name: Image digest
run: |
echo $"\
Digest: ${{ steps.docker_build.outputs.digest }}
Tags: ${{ env.CONTAINER_TAGS }}"
Tags: ${{ steps.meta.outputs.tags }}"

0 comments on commit bef2cbd

Please sign in to comment.