Skip to content

adjustment for ghcrio tags #8

adjustment for ghcrio tags

adjustment for ghcrio tags #8

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
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 }}-${{ matrix.container }}
tags: |
type=raw,value=latest
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Build and push Docker image
if: github.event_name != 'pull_request'
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: 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