diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index cd335b7..505dca1 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,11 +1,11 @@ -name: ci +name: docker on: push: branches: - 'main' - tags: - - 'v*.*.*' + release: + types: [created] pull_request: branches: - 'main' @@ -43,8 +43,14 @@ jobs: with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + + # Parse the tag into semver. + - uses: gacts/github-slug@v1 + id: slug + - name: Build and push + if: github.event_name != 'release' uses: docker/build-push-action@v2 with: context: . @@ -53,6 +59,20 @@ jobs: tags: nitnelave/lldap:latest cache-from: type=gha 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 if: github.event_name != 'pull_request' diff --git a/README.md b/README.md index 9f3a681..439e4be 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ volumes: services: lldap: - image: nitnelave/lldap + image: nitnelave/lldap:stable # Change this to the user:group you want. user: "33:33" ports: