Skip to content

Update build-and-deploy.yml #37

Update build-and-deploy.yml

Update build-and-deploy.yml #37

name: Build and Publish Docker Image
on:
push:
branches:
- main
- dev
tags:
- 'v*' # Triggers on version tags
pull_request:
branches:
- main
- dev
workflow_dispatch: # Allows manual triggering of the workflow
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
platform:
- linux/amd64
- linux/arm64
- linux/arm/v7
- linux/arm/v6
- linux/386
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push the Docker image
uses: docker/build-push-action@v6
with:
context: smtp2mqtt
file: smtp2mqtt/Dockerfile
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}-${{ matrix.platform == 'linux/amd64' && 'amd64' || matrix.platform == 'linux/arm64' && 'arm64' || matrix.platform == 'linux/arm/v7' && 'armv7' || matrix.platform == 'linux/arm/v6' && 'armv6' || 'i386' }}:${{ github.ref == 'refs/tags/*' && github.ref_name || github.ref == 'refs/heads/main' && 'latest' || github.ref == 'refs/heads/dev' && 'dev' || (github.event_name == 'pull_request' && format('pr-{0}', github.event.number)) || 'dev' }}
platforms: ${{ matrix.platform }}
build-args: |
BUILD_FROM=python:3.11-alpine