Skip to content

Build and Push Docker Images #52

Build and Push Docker Images

Build and Push Docker Images #52

Workflow file for this run

name: Build and Push Docker Images
# The master branch will have the :latest tag will will be kept one to one with the latest versioned release.
on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to build (optional)'
required: false
schedule:
- cron: "0 0 * * 1"
push:
branches:
- 'Master'
- 'v1.*'
paths:
- Dockerfile
jobs:
build_and_push:
name: Build and Push Docker Image
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
branch:
- Master
- v1.11.5
- v1.11.6
- v1.11.7
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch || matrix.branch }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Prepare tags and version
shell: bash
run: |
if [[ "${{ matrix.branch }}" == "Master" ]]; then
# Dynamically fetch the latest version tag for the Master branch
LATEST_VERSION=$(git tag | grep '^v' | sort -V | tail -n1)
echo "VERSION_TAG=$LATEST_VERSION" >> $GITHUB_ENV
echo "TAGS=ghcr.io/blueprintframework/blueprint:latest" >> $GITHUB_ENV
else
# Use the branch name as the version tag
echo "VERSION_TAG=${{ matrix.branch }}" >> $GITHUB_ENV
echo "TAGS=ghcr.io/blueprintframework/blueprint:${{ matrix.branch }}" >> $GITHUB_ENV
fi
- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: true
tags: ${{ env.TAGS }}