2023-02-01 13:47:38 +00:00
|
|
|
name: Publish Docker image on Push to Master
|
|
|
|
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches: [ master ]
|
|
|
|
paths:
|
|
|
|
- 'pkg/**'
|
|
|
|
- 'cmd/**'
|
|
|
|
- 'plugins/**'
|
|
|
|
- 'docker/docker_start.sh'
|
|
|
|
- 'docker/config.yaml'
|
|
|
|
- '.github/workflows/publish_docker-image_on_master.yml'
|
|
|
|
- 'Dockerfile'
|
|
|
|
- 'go.mod'
|
|
|
|
- 'go.sum'
|
|
|
|
- 'Makefile'
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
push_to_registry:
|
|
|
|
name: Push Docker image to Docker Hub
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Check out the repo
|
|
|
|
uses: actions/checkout@v3
|
2023-02-01 15:55:34 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2023-02-01 13:47:38 +00:00
|
|
|
- name: Prepare
|
|
|
|
id: prep
|
|
|
|
run: |
|
|
|
|
DOCKER_IMAGE=crowdsecurity/crowdsec
|
|
|
|
GHCR_IMAGE=ghcr.io/${{ github.repository_owner }}/crowdsec
|
|
|
|
VERSION=dev
|
|
|
|
TAGS="${DOCKER_IMAGE}:${VERSION},${GHCR_IMAGE}:${VERSION}"
|
|
|
|
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
|
|
|
|
- name: Login to DockerHub
|
|
|
|
uses: docker/login-action@v2
|
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
|
|
|
|
- name: Login to GitHub Container Registry
|
2023-02-02 08:49:52 +00:00
|
|
|
uses: docker/login-action@v2
|
2023-02-01 13:47:38 +00:00
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.repository_owner }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
|
|
|
- name: Build and push full image
|
2023-02-02 08:49:52 +00:00
|
|
|
uses: docker/build-push-action@v4
|
2023-02-01 13:47:38 +00:00
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
file: ./Dockerfile
|
|
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
|
|
tags: ${{ steps.prep.outputs.tags }}
|
|
|
|
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/386
|
|
|
|
labels: |
|
|
|
|
org.opencontainers.image.source=${{ github.event.repository.html_url }}
|
|
|
|
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
|
|
|
|
org.opencontainers.image.revision=${{ github.sha }}
|