🚀 RELEASE: First working release, version bumped to 1.0.0
. 🎉. (#1)
#11
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
#@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 | |
id: extract_branch | |
shell: bash | |
run: | | |
BRANCH_NAME=$(echo ${{ github.ref }} | sed 's/refs\/heads\///') | |
echo "branch=$BRANCH_NAME" >> $GITHUB_ENV | |
echo "Extracted branch name: $BRANCH_NAME" | |
- name: Set version and channel | |
id: version_channel | |
run: | | |
BRANCH_NAME=${{ env.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" >> $GITHUB_ENV | |
echo "channel=$CHANNEL" >> $GITHUB_ENV | |
echo "Extracted version: $VERSION" | |
echo "Extracted channel: $CHANNEL" | |
echo "Extracted branch name: $BRANCH_NAME" | |
- name: Build and push | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
push: true | |
tags: | | |
ghcr.io/bearlike/meeseeks-chat:${{ env.version }}${{ env.channel == 'dev' && '-dev' || '' }} | |
ghcr.io/bearlike/meeseeks-chat:${{ env.channel == 'latest' && 'latest' || env.channel == 'stable' && 'stable' || 'dev' }} | |
platforms: linux/amd64,linux/arm64 |