2022-02-15 16:10:15 +00:00
|
|
|
name: Publish Docker Debian image
|
2022-06-17 14:12:49 +00:00
|
|
|
|
2022-02-15 16:10:15 +00:00
|
|
|
on:
|
|
|
|
release:
|
|
|
|
types:
|
|
|
|
- released
|
|
|
|
- prereleased
|
2022-02-28 11:04:31 +00:00
|
|
|
workflow_dispatch:
|
2022-06-17 14:12:49 +00:00
|
|
|
|
2022-02-15 16:10:15 +00:00
|
|
|
jobs:
|
|
|
|
push_to_registry:
|
|
|
|
name: Push Docker debian image to Docker Hub
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2023-02-01 15:55:34 +00:00
|
|
|
- name: Check out the repo
|
2022-04-05 09:00:11 +00:00
|
|
|
uses: actions/checkout@v3
|
2023-02-01 15:55:34 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
- name: Prepare
|
2022-02-15 16:10:15 +00:00
|
|
|
id: prep
|
|
|
|
run: |
|
|
|
|
DOCKER_IMAGE=crowdsecurity/crowdsec
|
|
|
|
VERSION=bullseye
|
|
|
|
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
|
|
|
VERSION=${GITHUB_REF#refs/tags/}
|
|
|
|
elif [[ $GITHUB_REF == refs/heads/* ]]; then
|
|
|
|
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -E 's#/+#-#g')
|
|
|
|
elif [[ $GITHUB_REF == refs/pull/* ]]; then
|
|
|
|
VERSION=pr-${{ github.event.number }}
|
|
|
|
fi
|
|
|
|
TAGS="${DOCKER_IMAGE}:${VERSION}-debian"
|
2023-05-16 13:24:31 +00:00
|
|
|
if [[ "${{ github.event.action }}" == "released" ]]; then
|
2022-02-15 16:10:15 +00:00
|
|
|
TAGS=$TAGS,${DOCKER_IMAGE}:latest-debian
|
|
|
|
fi
|
2023-02-01 15:55:34 +00:00
|
|
|
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
|
|
|
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
|
|
|
|
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
|
|
|
|
- name: Set up QEMU
|
2023-01-04 15:55:34 +00:00
|
|
|
uses: docker/setup-qemu-action@v2
|
2023-02-01 15:55:34 +00:00
|
|
|
- name: Set up Docker Buildx
|
2023-01-04 15:55:34 +00:00
|
|
|
uses: docker/setup-buildx-action@v2
|
2023-03-01 09:56:25 +00:00
|
|
|
with:
|
|
|
|
config: .github/buildkit.toml
|
|
|
|
|
2023-02-01 15:55:34 +00:00
|
|
|
- name: Login to DockerHub
|
2023-01-04 15:55:34 +00:00
|
|
|
uses: docker/login-action@v2
|
2022-02-15 16:10:15 +00:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
2023-02-01 15:55:34 +00:00
|
|
|
- name: Build and push
|
|
|
|
uses: docker/build-push-action@v4
|
2022-02-15 16:10:15 +00:00
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
file: ./Dockerfile.debian
|
|
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
|
|
tags: ${{ steps.prep.outputs.tags }}
|
2023-05-16 13:24:31 +00:00
|
|
|
platforms: linux/amd64,linux/arm64,linux/386
|
2022-02-15 16:10:15 +00:00
|
|
|
labels: |
|
|
|
|
org.opencontainers.image.source=${{ github.event.repository.html_url }}
|
|
|
|
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
|
|
|
|
org.opencontainers.image.revision=${{ github.sha }}
|