Skip to content

try fixing the label issues #7

try fixing the label issues

try fixing the label issues #7

name: Docker Build and Publish CI
on:
push:
branches: [ "main", "feature/publish-ghcrio"]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "main" ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: hamstring-ndr/hamstring
jobs:
build:
name: Docker ${{ matrix.container }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ "ubuntu-latest" ]
container: [ "detector",
"inspector",
"logcollector",
"logserver",
"prefilter",
"monitoring",
"zeek"
]
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5.5.1
with:
images: |
${{ env.REGISTRY }}/${{ github.repository }}
- name: Build and push Docker image (${{ steps.meta.outputs.tags }})
if: github.event_name != 'pull_request' && contains(github.ref, '/tags/v')
id: build-and-push
uses: docker/build-push-action@v3
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: "${{ steps.meta.outputs.tags }}"
labels: ${{ steps.meta.outputs.labels }}
file: ./docker/dockerfiles/Dockerfile.${{ matrix.container }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and push Docker image (latest)
id: build-and-push-latest
uses: docker/build-push-action@v3
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ env.IMAGE_NAME }}-${{ matrix.container }}:latest
labels: ${{ steps.meta.outputs.labels }}
file: ./docker/dockerfiles/Dockerfile.${{ matrix.container }}
cache-from: type=gha
cache-to: type=gha,mode=max
# - name: Docker Hub Description
# uses: peter-evans/dockerhub-description@v3
# if: github.event_name != 'pull_request'
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}
# repository: ${{ env.IMAGE_NAME }}-${{ matrix.container }}
# short-description: ${{ github.event.repository.description }}
# readme-filepath: ./README.md