Skip to content

Embedded Gateway Builder #7

Embedded Gateway Builder

Embedded Gateway Builder #7

Workflow file for this run

name: Embedded Gateway Builder
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag to push on Docker Hub'
required: true
push_image:
description: 'Push Docker image'
required: false
type: boolean
default: false
push:
branches:
- main
paths:
- .github/workflows/build-docker.yml
- Dockerfile
tags:
- 'v*'
jobs:
build:
name: Build and push embedded-gateway-builder image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Clone
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set tags based on event
env:
IMAGE_NAME: "ghcr.io/wirepas/embedded-gateway-builder"
run: |
# For a push triggered event, use the edge tag and push
if [[ "${{ github.event_name }}" == "push" ]]; then
echo "TAG=${IMAGE_NAME}:edge" >> $GITHUB_ENV
echo "PUSH_IMAGE=true" >> $GITHUB_ENV
# For a manually triggered event, use the provided input prefixed by "manual_" for the tag and push if needed
elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "TAG=${IMAGE_NAME}:manual_${{ github.event.inputs.tag }}" >> $GITHUB_ENV
echo "PUSH_IMAGE=${{ github.event.inputs.push_image || 'false' }}" >> $GITHUB_ENV
# For a tag triggered event, use the version for the tag and push
elif [[ "${{ github.event_name }}" == "tag" ]]; then
echo "TAG=${IMAGE_NAME}:${{ github.ref_name }}" >> $GITHUB_ENV
echo "PUSH_IMAGE=true" >> $GITHUB_ENV
fi
- name: Build and push embedded-gateway-builder to GitHub Packages
uses: docker/build-push-action@v6
with:
push: ${{ env.PUSH_IMAGE }}
tags: ${{ env.TAG }}