Skip to content

Commit 6617f65

Browse files
committed
CI: docker build
1 parent 742df38 commit 6617f65

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Publish Docker image
2+
3+
on:
4+
release:
5+
types:
6+
- released
7+
- prereleased
8+
9+
permissions:
10+
contents: read
11+
packages: write
12+
13+
jobs:
14+
push_to_registry:
15+
name: Push Docker image to Docker Hub
16+
runs-on: ubuntu-latest
17+
steps:
18+
-
19+
name: Check out the repo
20+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
21+
with:
22+
fetch-depth: 0
23+
-
24+
name: Prepare
25+
id: prep
26+
run: |
27+
DOCKER_IMAGE=crowdsecurity/haproxy-spoa-bouncer
28+
GHCR_IMAGE=ghcr.io/${{ github.repository_owner }}/haproxy-spoa-bouncer
29+
VERSION=edge
30+
if [[ $GITHUB_REF == refs/tags/* ]]; then
31+
VERSION=${GITHUB_REF#refs/tags/}
32+
elif [[ $GITHUB_REF == refs/heads/* ]]; then
33+
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -E 's#/+#-#g')
34+
elif [[ $GITHUB_REF == refs/pull/* ]]; then
35+
VERSION=pr-${{ github.event.number }}
36+
fi
37+
TAGS="${DOCKER_IMAGE}:${VERSION},${GHCR_IMAGE}:${VERSION}"
38+
if [[ "${{ github.event_name }}" == "release" && "${{ github.event.release.prerelease }}" == "false" ]]; then
39+
TAGS=$TAGS,${DOCKER_IMAGE}:latest,${GHCR_IMAGE}:latest
40+
fi
41+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
42+
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
43+
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
44+
-
45+
name: Set up QEMU
46+
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
47+
-
48+
name: Set up Docker Buildx
49+
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
50+
-
51+
name: Login to DockerHub
52+
if: github.event_name == 'release'
53+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
54+
with:
55+
username: ${{ secrets.DOCKER_USERNAME }}
56+
password: ${{ secrets.DOCKER_PASSWORD }}
57+
58+
- name: Login to GitHub Container Registry
59+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
60+
with:
61+
registry: ghcr.io
62+
username: ${{ github.repository_owner }}
63+
password: ${{ secrets.GITHUB_TOKEN }}
64+
-
65+
name: Build and push
66+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
67+
with:
68+
context: .
69+
file: ./Dockerfile
70+
push: ${{ github.event_name == 'release' }}
71+
tags: ${{ steps.prep.outputs.tags }}
72+
# Supported by golang:1.18-alpine: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
73+
# Supported by alpine: same
74+
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
75+
labels: |
76+
org.opencontainers.image.source=${{ github.event.repository.html_url }}
77+
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
78+
org.opencontainers.image.revision=${{ github.sha }}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: (push-master) Update Docker Hub README
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- 'docker/README.md'
9+
10+
jobs:
11+
update-docker-hub-readme:
12+
runs-on: ubuntu-latest
13+
steps:
14+
15+
-
16+
name: Check out the repo
17+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3
18+
if: ${{ github.repository_owner == 'crowdsecurity' }}
19+
20+
-
21+
name: Update docker hub README
22+
uses: peter-evans/dockerhub-description@1b9a80c056b620d92cedb9d9b5a223409c68ddfa
23+
if: ${{ github.repository_owner == 'crowdsecurity' }}
24+
with:
25+
username: ${{ secrets.DOCKER_USERNAME }}
26+
password: ${{ secrets.DOCKER_PASSWORD }}
27+
repository: crowdsecurity/haproxy-spoa-bouncer
28+
readme-filepath: "./docker/README.md"

0 commit comments

Comments
 (0)