docker: Create a tagged image on release

This commit is contained in:
Valentin Tolmer 2021-11-29 09:41:47 +01:00 committed by nitnelave
parent 842afac7dd
commit 68013c8919
2 changed files with 24 additions and 4 deletions

View File

@ -1,11 +1,11 @@
name: ci name: docker
on: on:
push: push:
branches: branches:
- 'main' - 'main'
tags: release:
- 'v*.*.*' types: [created]
pull_request: pull_request:
branches: branches:
- 'main' - 'main'
@ -43,8 +43,14 @@ jobs:
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
# Parse the tag into semver.
- uses: gacts/github-slug@v1
id: slug
- -
name: Build and push name: Build and push
if: github.event_name != 'release'
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
context: . context: .
@ -53,6 +59,20 @@ jobs:
tags: nitnelave/lldap:latest tags: nitnelave/lldap:latest
cache-from: type=gha cache-from: type=gha
cache-to: type=gha,mode=max cache-to: type=gha,mode=max
-
name: Build and push
if: github.event_name == 'release'
uses: docker/build-push-action@v2
with:
context: .
push: true
platforms: linux/amd64
# Tag as latest, stable, semver, major, major.minor and major.minor.patch.
tags: nitnelave/lldap:latest, nitnelave/lldap:stable, nitnelave/lldap:v${{ steps.slug.outputs.version-semantic }}, nitnelave/lldap:v${{ steps.slug.outputs.version-major }}, nitnelave/lldap:v${{ steps.slug.outputs.version-major }}.${{ steps.slug.outputs.version-minor }}, nitnelave/lldap:v${{ steps.slug.outputs.version-major }}.${{ steps.slug.outputs.version-minor }}.${{ steps.slug.outputs.version-patch }}
cache-from: type=gha
cache-to: type=gha,mode=max
- -
name: Update repo description name: Update repo description
if: github.event_name != 'pull_request' if: github.event_name != 'pull_request'

View File

@ -82,7 +82,7 @@ volumes:
services: services:
lldap: lldap:
image: nitnelave/lldap image: nitnelave/lldap:stable
# Change this to the user:group you want. # Change this to the user:group you want.
user: "33:33" user: "33:33"
ports: ports: