ci: fix pushing for develop branch

This commit is contained in:
Eduard Marbach 2021-01-01 14:28:58 +01:00
parent 31c13d889a
commit 353c2f5fdb

View File

@ -3,6 +3,7 @@ name: CI
env: env:
DEFAULT_DOCKER_IMAGE: nicolargo/glances DEFAULT_DOCKER_IMAGE: nicolargo/glances
NODE_ENV: ${{ (contains('refs/heads/master', github.ref) || startsWith(github.ref, 'refs/tags/v')) && 'prod' || 'dev' }} NODE_ENV: ${{ (contains('refs/heads/master', github.ref) || startsWith(github.ref, 'refs/tags/v')) && 'prod' || 'dev' }}
PUSH_BRANCH: ${{ 'refs/heads/develop' == github.ref || 'refs/heads/master' == github.ref || startsWith(github.ref, 'refs/tags/v') }}
DOCKER_PLATFORMS: linux/amd64,linux/arm/v7,linux/arm64,linux/386 DOCKER_PLATFORMS: linux/amd64,linux/arm/v7,linux/arm64,linux/386
on: on:
@ -32,7 +33,6 @@ jobs:
env: env:
DOCKER_IMAGE: ${{ secrets.DOCKER_IMAGE || env.DEFAULT_DOCKER_IMAGE }} DOCKER_IMAGE: ${{ secrets.DOCKER_IMAGE || env.DEFAULT_DOCKER_IMAGE }}
DOCKERFILE: ${{ env.NODE_ENV == 'prod' && './docker-files/Dockerfile' || './docker-files/dev.Dockerfile' }} DOCKERFILE: ${{ env.NODE_ENV == 'prod' && './docker-files/Dockerfile' || './docker-files/dev.Dockerfile' }}
PUSH_IMAGE: ${{ env.NODE_ENV == 'prod' && 'true' || 'false' }}
run: | run: |
ls -la /tmp/.buildx-cache || true ls -la /tmp/.buildx-cache || true
VERSION=latest VERSION=latest
@ -47,7 +47,6 @@ jobs:
echo "DOCKERFILE=${DOCKERFILE}" >> $GITHUB_ENV echo "DOCKERFILE=${DOCKERFILE}" >> $GITHUB_ENV
echo "VERSION=${VERSION}" >> $GITHUB_ENV echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "PUSH_IMAGE=${PUSH_IMAGE}" >> $GITHUB_ENV
echo "TAGS=${DOCKER_IMAGE}:${VERSION}" >> $GITHUB_ENV echo "TAGS=${DOCKER_IMAGE}:${VERSION}" >> $GITHUB_ENV
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
echo "VCS_REF=${GITHUB_SHA::8}" >> $GITHUB_ENV echo "VCS_REF=${GITHUB_SHA::8}" >> $GITHUB_ENV
@ -65,7 +64,7 @@ jobs:
- name: Login to DockerHub - name: Login to DockerHub
uses: docker/login-action@v1 uses: docker/login-action@v1
if: ${{env.PUSH_IMAGE == 'true'}} if: ${{ env.PUSH_BRANCH == 'true' }}
with: with:
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ secrets.DOCKER_PASSWORD }}
@ -73,7 +72,7 @@ jobs:
- name: Build and push - name: Build and push
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
push: ${{env.PUSH_IMAGE == 'true'}} push: ${{ env.PUSH_BRANCH == 'true' }}
tags: ${{env.TAGS}} tags: ${{env.TAGS}}
build-args: | build-args: |
VERSION=${{env.VERSION}} VERSION=${{env.VERSION}}