Skip to content

Commit

Permalink
📦 NEW: Add Docker build workflow with multi-arch support.
Browse files Browse the repository at this point in the history
  • Loading branch information
bearlike committed May 11, 2024
1 parent 96ea377 commit c719bf6
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/docker-buildx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#@doc
# * This GitHub Actions workflow builds and pushes a Docker image to GitHub Container Registry.
# * It is triggered when a branch is created with the name syntax "release/[version]-[channel]".
#
# The workflow does the following:
# 1. Checks out the code, sets up Docker buildx, Login to the registry.
# 2. Extracts the branch name from the GITHUB_REF environment variable.
# 3. Splits the branch name to get the version and channel.
# 4. Builds and pushes the Docker image.

# Examples:
# If the branch name is 'release/1.0.0-latest', the image is tagged as '1.0.0' and 'latest'.
# If the branch name is 'release/1.0.1-stable', the image is tagged as '1.0.1' and 'stable'.
# If the branch name is 'release/1.0.2-dev', the image is tagged as '1.0.2-dev'.
#
# * The 'latest' and 'stable' tags allow us to easily switch between different versions.
# * The 'dev' tag allows you to have a separate version for development.

name: Build Meseeks Chat Docker Image

on:
workflow_dispatch:
push:
branches:
- 'release/*'

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

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

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

- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch

- name: Set version and channel
id: version_channel
run: |
BRANCH_NAME=${{ steps.extract_branch.outputs.branch }}
VERSION=$(echo $BRANCH_NAME | cut -d'/' -f 2 | cut -d'-' -f 1)
CHANNEL=$(echo $BRANCH_NAME | cut -d'/' -f 2 | cut -d'-' -f 2)
echo "VERSION=$VERSION"
echo "CHANNEL=$CHANNEL"
echo "::set-output name=version::$VERSION"
echo "::set-output name=channel::$CHANNEL"
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: |
ghcr.io/bearlike/meeseeks-chat:${{ steps.version_channel.outputs.version }}${{ steps.version_channel.outputs.channel == 'dev' && '-dev' || '' }}
ghcr.io/bearlike/meeseeks-chat:${{ steps.version_channel.outputs.channel == 'latest' && 'latest' || steps.version_channel.outputs.channel == 'stable' && 'stable' || '' }}
platforms: linux/amd64,linux/arm64,linux/arm/v7

0 comments on commit c719bf6

Please sign in to comment.