-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
📦 NEW: Add Docker build workflow with multi-arch support.
- Loading branch information
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |