mirror of
https://github.com/hhftechnology/middleware-manager.git
synced 2026-01-06 08:10:12 -06:00
71 lines
1.9 KiB
YAML
71 lines
1.9 KiB
YAML
name: Build and Push Docker Image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- traefik-int
|
|
paths:
|
|
- 'Dockerfile'
|
|
- 'go.mod'
|
|
- 'go.sum'
|
|
- 'main.go'
|
|
- 'Makefile'
|
|
- '.github/workflows/**'
|
|
- 'api/**'
|
|
- 'config/**'
|
|
- 'database/**'
|
|
- 'models/**'
|
|
- 'services/**'
|
|
- 'ui/**'
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
DOCKERHUB_IMAGE_NAME: hhftechnology/middleware-manager
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout Repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Debug trigger
|
|
run: |
|
|
echo "Event: ${{ github.event_name }}"
|
|
echo "Ref: ${{ github.ref }}"
|
|
echo "Ref name: ${{ github.ref_name }}"
|
|
echo "Branch: ${{ github.ref_type == 'branch' && github.ref_name || 'not a branch' }}"
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
# Prepare tags based on branch and version
|
|
- name: Prepare Docker tags
|
|
id: docker_tags
|
|
run: |
|
|
TAGS=""
|
|
if [[ "${{ github.ref_type }}" == "branch" && "${{ github.ref_name }}" == "traefik-int" ]]; then
|
|
TAGS="${{ env.DOCKERHUB_IMAGE_NAME }}:traefik-int"
|
|
fi
|
|
echo "tags=$TAGS" >> $GITHUB_OUTPUT
|
|
echo "Docker tags: $TAGS"
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: ${{ steps.docker_tags.outputs.tags != '' }} # IMPORTANT: Only push if tags were generated
|
|
platforms: linux/amd64,linux/arm64
|
|
tags: ${{ steps.docker_tags.outputs.tags }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|