Add ci docker push (#504)
This commit is contained in:
parent
7831dabaa8
commit
28c1ea1e23
2 changed files with 68 additions and 0 deletions
62
.github/workflows/release_publish_docker-image.yml
vendored
Normal file
62
.github/workflows/release_publish_docker-image.yml
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
name: Publish Docker image
|
||||
on:
|
||||
release:
|
||||
types:
|
||||
- released
|
||||
- prereleased
|
||||
jobs:
|
||||
push_to_registry:
|
||||
name: Push Docker image to Docker Hub
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
name: Check out the repo
|
||||
uses: actions/checkout@v2
|
||||
-
|
||||
name: Prepare
|
||||
id: prep
|
||||
run: |
|
||||
DOCKER_IMAGE=crowdsecurity/crowdsec
|
||||
VERSION=edge
|
||||
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
||||
VERSION=${GITHUB_REF#refs/tags/}
|
||||
elif [[ $GITHUB_REF == refs/heads/* ]]; then
|
||||
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
|
||||
elif [[ $GITHUB_REF == refs/pull/* ]]; then
|
||||
VERSION=pr-${{ github.event.number }}
|
||||
fi
|
||||
TAGS="${DOCKER_IMAGE}:${VERSION}"
|
||||
echo ::set-output name=docker_image::${DOCKER_IMAGE}
|
||||
echo ::set-output name=version::${VERSION}
|
||||
echo ::set-output name=tags::${TAGS}
|
||||
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
||||
-
|
||||
name: Tag Latest
|
||||
id: prep_tag_latest
|
||||
if: "github.event.release.release"
|
||||
run: |
|
||||
TAGS=${{ steps.prep.outputs.tags }},${{ steps.prep.outputs.docker_image }}:latest
|
||||
echo ::set-output name=tags::${TAGS}
|
||||
echo ::set-output name=version::${{ steps.prep.outputs.version }}
|
||||
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
-
|
||||
name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
-
|
||||
name: Build and push
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.prep.outputs.tags }}
|
||||
labels: |
|
||||
org.opencontainers.image.source=${{ github.event.repository.html_url }}
|
||||
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
|
||||
org.opencontainers.image.revision=${{ github.sha }}
|
|
@ -95,6 +95,12 @@ cd crowdsec-v*
|
|||
sudo ./wizard.sh -i
|
||||
```
|
||||
|
||||
## :whale2: Docker
|
||||
|
||||
You can use docker to run crowdsec, by using [official docker image](https://hub.docker.com/r/crowdsecurity/crowdsec).
|
||||
|
||||
You can also build the docker image following [this](https://github.com/crowdsecurity/crowdsec/tree/master/docker#build)
|
||||
|
||||
## ⚙️ Build it !
|
||||
|
||||
If you want to build crowdsec yourself follow these steps:
|
||||
|
|
Loading…
Add table
Reference in a new issue