99 lines
3 KiB
YAML
99 lines
3 KiB
YAML
|
name: Publish Docker image / platform
|
||
|
|
||
|
on:
|
||
|
workflow_call:
|
||
|
secrets:
|
||
|
DOCKER_USERNAME:
|
||
|
required: true
|
||
|
DOCKER_PASSWORD:
|
||
|
required: true
|
||
|
inputs:
|
||
|
platform:
|
||
|
required: true
|
||
|
type: string
|
||
|
image_version:
|
||
|
required: true
|
||
|
type: string
|
||
|
crowdsec_version:
|
||
|
required: true
|
||
|
type: string
|
||
|
latest:
|
||
|
required: true
|
||
|
type: boolean
|
||
|
push:
|
||
|
required: true
|
||
|
type: boolean
|
||
|
slim:
|
||
|
required: true
|
||
|
type: boolean
|
||
|
debian:
|
||
|
required: true
|
||
|
type: boolean
|
||
|
|
||
|
jobs:
|
||
|
push_to_registry:
|
||
|
name: Push Docker image to registries
|
||
|
runs-on: ubuntu-latest
|
||
|
steps:
|
||
|
|
||
|
- name: Check out the repo
|
||
|
uses: actions/checkout@v3
|
||
|
with:
|
||
|
fetch-depth: 0
|
||
|
|
||
|
- name: Prepare
|
||
|
id: prep
|
||
|
run: |
|
||
|
DOCKERHUB_IMAGE=${{ secrets.DOCKER_USERNAME }}/crowdsec
|
||
|
GHCR_IMAGE=ghcr.io/${{ github.repository_owner }}/crowdsec
|
||
|
VERSION=${{ inputs.image_version }}
|
||
|
SLIM=${{ inputs.slim && '-slim' || '' }}
|
||
|
DEBIAN=${{ inputs.debian && '-debian' || '' }}
|
||
|
TAGS="${DOCKERHUB_IMAGE}:${VERSION}${SLIM}${DEBIAN},${GHCR_IMAGE}:${VERSION}${SLIM}${DEBIAN}"
|
||
|
if [[ ${{ inputs.latest }} == true ]]; then
|
||
|
if [[ ${{ inputs.slim }} == true ]]; then
|
||
|
TAGS=$TAGS,${DOCKERHUB_IMAGE}:slim${DEBIAN},${GHCR_IMAGE}:slim${DEBIAN}
|
||
|
else
|
||
|
TAGS=$TAGS,${DOCKERHUB_IMAGE}:latest${DEBIAN},${GHCR_IMAGE}:latest${DEBIAN}
|
||
|
fi
|
||
|
fi
|
||
|
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
|
||
|
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
|
||
|
|
||
|
- name: Set up QEMU
|
||
|
uses: docker/setup-qemu-action@v2
|
||
|
|
||
|
- name: Set up Docker Buildx
|
||
|
uses: docker/setup-buildx-action@v2
|
||
|
with:
|
||
|
config: .github/buildkit.toml
|
||
|
|
||
|
- name: Login to DockerHub
|
||
|
uses: docker/login-action@v2
|
||
|
with:
|
||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||
|
|
||
|
- name: Login to GitHub Container Registry
|
||
|
uses: docker/login-action@v2
|
||
|
with:
|
||
|
registry: ghcr.io
|
||
|
username: ${{ github.repository_owner }}
|
||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||
|
|
||
|
- name: Build and push image
|
||
|
uses: docker/build-push-action@v4
|
||
|
with:
|
||
|
context: .
|
||
|
file: ./Dockerfile${{ inputs.debian && '.debian' || '' }}
|
||
|
push: ${{ inputs.push }}
|
||
|
tags: ${{ steps.prep.outputs.tags }}
|
||
|
target: ${{ inputs.slim && 'slim' || 'full' }}
|
||
|
platforms: ${{ inputs.platform }}
|
||
|
labels: |
|
||
|
org.opencontainers.image.source=${{ github.event.repository.html_url }}
|
||
|
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
|
||
|
org.opencontainers.image.revision=${{ github.sha }}
|
||
|
build-args: |
|
||
|
BUILD_VERSION=${{ inputs.crowdsec_version }}
|