Update Docker_build.yml

This commit is contained in:
Florian BEZANNIER
2021-05-07 11:39:24 +02:00
committed by GitHub
parent 1a8aaa583a
commit 97347dabd0
+29 -6
View File
@@ -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 }}