🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.
ci: standardize formatting and improve readability in docker-publish workflow
Bill Yang3bbfbb6d5804
diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.ymlindex d1cf302f7..4c031c091 100644--- a/.github/workflows/docker-publish.yml+++ b/.github/workflows/docker-publish.yml@@ -3,47 +3,47 @@ name: Docker Publishon:push:branches:- - master # Trigger workflow on push to master branch+ - master # Trigger workflow on push to master branchtags:- - 'v*' # Trigger workflow on version tag push (e.g., v1.2.3)+ - "v*" # Trigger workflow on version tag push (e.g., v1.2.3)+ pull_request:+ branches:+ - master # Trigger workflow on pull requests to master branchjobs:-client:-name: Build Client Imagespermissions:- contents: read # Allows reading repository contents- packages: write # Required to push images to GitHub Container Registry (GHCR)+ contents: read # Allows reading repository contents+ packages: write # Required to push images to GitHub Container Registry (GHCR)strategy:- fail-fast: false # Continue building other platforms even if one fails+ fail-fast: false # Continue building other platforms even if one failsmatrix:include:- os: ubuntu-latestarch: amd64- platform: linux/amd64 # x86_64 architecture+ platform: linux/amd64 # x86_64 architecture- os: ubuntu-24.04-armarch: arm64- platform: linux/arm64 # ARM architecture+ platform: linux/arm64 # ARM architecture- runs-on: ${{ matrix.os }} # Use the selected OS from the matrix+ runs-on: ${{ matrix.os }} # Use the selected OS from the matrixsteps:-- name: Checkout repository- uses: actions/checkout@v4 # Checkout the code from the repository+ uses: actions/checkout@v4 # Checkout the code from the repository- name: Log in to GitHub Container Registryuses: docker/login-action@v3with:- registry: ghcr.io # GitHub Container Registry URL- username: ${{ github.repository_owner }} # GitHub repository owner- password: ${{ secrets.GITHUB_TOKEN }} # Token to authenticate with GHCR+ registry: ghcr.io # GitHub Container Registry URL+ username: ${{ github.repository_owner }} # GitHub repository owner+ password: ${{ secrets.GITHUB_TOKEN }} # Token to authenticate with GHCR- name: Set up Docker Buildx- uses: docker/setup-buildx-action@v3 # Set up Docker Buildx for building multi-platform images+ uses: docker/setup-buildx-action@v3 # Set up Docker Buildx for building multi-platform images- name: Prepare Environment Variables for Buildrun: |@@ -70,9 +70,9 @@ jobs:id: builduses: docker/build-push-action@v6with:- context: ./client # Path to the Dockerfile for the client- file: ./client/Dockerfile # Dockerfile for the client- platforms: ${{ matrix.platform }} # Build the image for the platform specified in the matrix+ context: ./client # Path to the Dockerfile for the client+ file: ./client/Dockerfile # Dockerfile for the client+ platforms: ${{ matrix.platform }} # Build the image for the platform specified in the matrixlabels: ${{ steps.meta.outputs.labels }}# Push image by digest only; manifest list will be created lateroutputs: type=image,"name=ghcr.io/${{ env.REPO_OWNER }}/rybbit-client",push-by-digest=true,name-canonical=true,push=true@@ -87,46 +87,44 @@ jobs:- name: Upload digestuses: actions/upload-artifact@v4with:- name: digests-client-${{ env.PLATFORM_PAIR }} # Name of the artifact (unique per platform)- path: /tmp/digests/* # Path to the digests files- if-no-files-found: error # Fail if no files are found- retention-days: 1 # Retain artifacts for 1 day+ name: digests-client-${{ env.PLATFORM_PAIR }} # Name of the artifact (unique per platform)+ path: /tmp/digests/* # Path to the digests files+ if-no-files-found: error # Fail if no files are found+ retention-days: 1 # Retain artifacts for 1 daybackend:-name: Build Backend Imagespermissions:- contents: read # Allows reading repository contents- packages: write # Required to push images to GitHub Container Registry (GHCR)+ contents: read # Allows reading repository contents+ packages: write # Required to push images to GitHub Container Registry (GHCR)strategy:- fail-fast: false # Continue building other platforms even if one fails+ fail-fast: false # Continue building other platforms even if one failsmatrix:include:- os: ubuntu-latestarch: amd64- platform: linux/amd64 # x86_64 architecture+ platform: linux/amd64 # x86_64 architecture- os: ubuntu-24.04-armarch: arm64- platform: linux/arm64 # ARM architecture+ platform: linux/arm64 # ARM architecture- runs-on: ${{ matrix.os }} # Use the selected OS from the matrix+ runs-on: ${{ matrix.os }} # Use the selected OS from the matrixsteps:-- name: Checkout repository- uses: actions/checkout@v4 # Checkout the code from the repository+ uses: actions/checkout@v4 # Checkout the code from the repository- name: Log in to GitHub Container Registryuses: docker/login-action@v3with:- registry: ghcr.io # GitHub Container Registry URL- username: ${{ github.repository_owner }} # GitHub repository owner- password: ${{ secrets.GITHUB_TOKEN }} # Token to authenticate with GHCR+ registry: ghcr.io # GitHub Container Registry URL+ username: ${{ github.repository_owner }} # GitHub repository owner+ password: ${{ secrets.GITHUB_TOKEN }} # Token to authenticate with GHCR- name: Set up Docker Buildx- uses: docker/setup-buildx-action@v3 # Set up Docker Buildx for building multi-platform images+ uses: docker/setup-buildx-action@v3 # Set up Docker Buildx for building multi-platform images- name: Prepare Environment Variables for Buildrun: |@@ -153,9 +151,9 @@ jobs:id: builduses: docker/build-push-action@v6with:- context: ./server # Path to the Dockerfile for the backend- file: ./server/Dockerfile # Dockerfile for the backend- platforms: ${{ matrix.platform }} # Build the image for the platform specified in the matrix+ context: ./server # Path to the Dockerfile for the backend+ file: ./server/Dockerfile # Dockerfile for the backend+ platforms: ${{ matrix.platform }} # Build the image for the platform specified in the matrixlabels: ${{ steps.meta.outputs.labels }}# Push image by digest only; manifest list will be created lateroutputs: type=image,"name=ghcr.io/${{ env.REPO_OWNER }}/rybbit-backend",push-by-digest=true,name-canonical=true,push=true@@ -170,33 +168,31 @@ jobs:- name: Upload digestuses: actions/upload-artifact@v4with:- name: digests-backend-${{ env.PLATFORM_PAIR }} # Name of the artifact (unique per platform)- path: /tmp/digests/* # Path to the digests files- if-no-files-found: error # Fail if no files are found- retention-days: 1 # Retain artifacts for 1 day+ name: digests-backend-${{ env.PLATFORM_PAIR }} # Name of the artifact (unique per platform)+ path: /tmp/digests/* # Path to the digests files+ if-no-files-found: error # Fail if no files are found+ retention-days: 1 # Retain artifacts for 1 daymerge:-name: Merge Images and Pushruns-on: ubuntu-latestneeds:- - backend # Wait for client before running the merge job- - client # Wait for client before running the merge job+ - backend # Wait for client before running the merge job+ - client # Wait for client before running the merge jobpermissions:- contents: read # Allows reading repository contents- packages: write # Required to push images to GitHub Container Registry (GHCR)+ contents: read # Allows reading repository contents+ packages: write # Required to push images to GitHub Container Registry (GHCR)steps:-- name: Download digestsuses: actions/download-artifact@v4with:- path: /tmp/digests # Download the digests to the /tmp/digests directory- pattern: digests-* # Match all artifacts starting with 'digests-'- merge-multiple: true # Merge all platform digests into one folder+ path: /tmp/digests # Download the digests to the /tmp/digests directory+ pattern: digests-* # Match all artifacts starting with 'digests-'+ merge-multiple: true # Merge all platform digests into one folder- name: Prepare Environment Variables for Mergerun: |@@ -206,12 +202,12 @@ jobs:- name: Log in to GitHub Container Registryuses: docker/login-action@v3with:- registry: ghcr.io # GitHub Container Registry URL- username: ${{ github.repository_owner }} # GitHub repository owner- password: ${{ secrets.GITHUB_TOKEN }} # Token to authenticate with GHCR+ registry: ghcr.io # GitHub Container Registry URL+ username: ${{ github.repository_owner }} # GitHub repository owner+ password: ${{ secrets.GITHUB_TOKEN }} # Token to authenticate with GHCR- name: Set up Docker Buildx- uses: docker/setup-buildx-action@v3 # Set up Docker Buildx for multi-platform builds+ uses: docker/setup-buildx-action@v3 # Set up Docker Buildx for multi-platform builds- name: Extract client metadata (tags, labels)id: client-meta@@ -221,21 +217,24 @@ jobs:tags: |# Add 'latest' tag only if this is a version tag (e.g., v1.2.3)${{ startsWith(github.ref, 'refs/tags/v') && 'type=raw,value=latest,priority=901' || '' }}-+# Add the version tag itself (e.g., v1.2.3)${{ startsWith(github.ref, 'refs/tags/v') && format('type=raw,value={0},priority=900', github.ref_name) || '' }}-++ # For pull requests, add PR number tag+ ${{ github.event_name == 'pull_request' && format('type=raw,value=pr-{0},priority=850', github.event.number) || '' }}+# Always add 'edge' tag for build on latest commit indicatortype=edge,priority=800-+# Always add short SHA tag for traceabilitytype=sha,priority=700- name: Create manifest list and push client images- working-directory: /tmp/digests # Change working directory to /tmp/digests+ working-directory: /tmp/digests # Change working directory to /tmp/digestsrun: |digests=""-+# Collect all the digests for the client componentfor file in client-*; dodigest=$(cat "$file")@@ -255,21 +254,24 @@ jobs:tags: |# Add 'latest' tag only if this is a version tag (e.g., v1.2.3)${{ startsWith(github.ref, 'refs/tags/v') && 'type=raw,value=latest,priority=901' || '' }}-+# Add the version tag itself (e.g., v1.2.3)${{ startsWith(github.ref, 'refs/tags/v') && format('type=raw,value={0},priority=900', github.ref_name) || '' }}-++ # For pull requests, add PR number tag+ ${{ github.event_name == 'pull_request' && format('type=raw,value=pr-{0},priority=850', github.event.number) || '' }}+# Always add 'edge' tag for build on latest commit indicatortype=edge,priority=800-+# Always add short SHA tag for traceabilitytype=sha,priority=700- name: Create manifest list and push backend images- working-directory: /tmp/digests # Change working directory to /tmp/digests+ working-directory: /tmp/digests # Change working directory to /tmp/digestsrun: |digests=""-+# Collect all the digests for the backend componentfor file in backend-*; dodigest=$(cat "$file")