fix: correct target key in Docker build workflow and add CMD for event scripts #14
Workflow file for this run
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: Build Snort3 Docker Image | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- "v*" | |
pull_request: | |
branches: | |
- main # Optional: Run the workflow on PRs target | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME_AGGREGATOR: ${{ github.repository }}-aggregator | |
IMAGE_NAME_PARSER: ${{ github.repository }}-parser | |
BUILDER_NAME: mybuilder | |
BUILD_PLATFORMS_TARGET: linux/amd64 | |
permissions: | |
contents: read | |
packages: write | |
attestations: write | |
id-token: write | |
jobs: | |
build-image: | |
runs-on: image-builder | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
logout: false | |
- name: Extract metadata (tags, labels) for Docker for service aggregator | |
id: meta-aggregator | |
if: github.event_name != 'pull_request' | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_AGGREGATOR }} | |
flavor: | | |
latest=auto | |
prefix= | |
suffix= | |
- name: Extract metadata (tags, labels) for Docker for service parser | |
id: meta-parser | |
if: github.event_name != 'pull_request' | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_PARSER }} | |
flavor: | | |
latest=auto | |
prefix= | |
suffix= | |
- name: Expose GitHub Runtime | |
if: github.event_name != 'pull_request' | |
uses: crazy-max/ghaction-github-runtime@v3 | |
- name: Build for Service opencti-connector-aggregator | |
id: push-aggregator | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: ./Dockerfile | |
target: event-aggregator | |
platforms: ${{ env.BUILD_PLATFORMS_TARGET }} | |
push: ${{ github.event_name != 'pull_request' }} | |
builder: ${{ env.BUILDER_NAME }} | |
tags: ${{ steps.meta-aggregator.outputs.tags }} | |
labels: ${{ steps.meta-aggregator.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Build for Service opencti-connector-parser | |
id: push-parser | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: ./Dockerfile | |
target: event-parser | |
platforms: ${{ env.BUILD_PLATFORMS_TARGET }} | |
push: ${{ github.event_name != 'pull_request' }} | |
builder: ${{ env.BUILDER_NAME }} | |
tags: ${{ steps.meta-parser.outputs.tags }} | |
labels: ${{ steps.meta-parser.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Generate artifact attestation for service aggregator | |
if: github.event_name != 'pull_request' | |
uses: actions/attest-build-provenance@v2 | |
with: | |
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_AGGREGATOR}} | |
subject-digest: ${{ steps.push-aggregator.outputs.digest }} | |
push-to-registry: true | |
- name: Generate artifact attestation for service parser | |
if: github.event_name != 'pull_request' | |
uses: actions/attest-build-provenance@v2 | |
with: | |
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_PARSER}} | |
subject-digest: ${{ steps.push-parser.outputs.digest }} | |
push-to-registry: true |