Embedded Gateway Builder #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
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 manually triggered event, use the provided input prefixed by "manual_" for the tag and push if needed | |
if [[ "${{ 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 push triggered event, use the edge tag and push | |
elif [[ "${{ github.event_name }}" == "push" ]] && [[ "${{ github.ref_type }}" != "tag" ]]; then | |
echo "TAG=${IMAGE_NAME}:edge" >> $GITHUB_ENV | |
echo "PUSH_IMAGE=true" >> $GITHUB_ENV | |
# For a tag triggered event, use the version for the tag and push | |
elif [[ "${{ github.event_name }}" == "push" ]] && [[ "${{ github.ref }}" == refs/tags/* ]]; 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 }} |