From 97347dabd02fee915f796a0236181d35dda67969 Mon Sep 17 00:00:00 2001 From: Florian BEZANNIER <48728684+flobz@users.noreply.github.com> Date: Fri, 7 May 2021 11:39:24 +0200 Subject: [PATCH] Update Docker_build.yml --- .github/workflows/Docker_build.yml | 35 +++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/.github/workflows/Docker_build.yml b/.github/workflows/Docker_build.yml index 5dc3fd7..8fa2667 100644 --- a/.github/workflows/Docker_build.yml +++ b/.github/workflows/Docker_build.yml @@ -8,12 +8,35 @@ jobs: name: Push Docker image to Docker Hub runs-on: ubuntu-latest steps: + - name: Prepare + id: prep + run: | + DOCKER_IMAGE=flobz/psa_car_controller + VERSION=edge + if [[ $GITHUB_REF == refs/tags/* ]]; then + VERSION=${GITHUB_REF#refs/tags/} + MINOR_VERSION=${VERSION%.*} + MAJOR=${VERSION%.*} + TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:${MINOR_VERSION},${DOCKER_IMAGE}:${MAJOR},${DOCKER_IMAGE}:latest" + else + TAGS="${DOCKER_IMAGE}:${VERSION}" + fi + echo ::set-output name=tags::${TAGS} - name: Check out the repo uses: actions/checkout@v2 - - name: Push to Docker Hub - uses: docker/build-push-action@v1 + - name: Login to DockerHub + uses: docker/login-action@v1 with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - repository: flobz/public/ - tag_with_ref: true + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ${{ steps.prep.outputs.tags }} + - + name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }}