1
Fork 0

Add back docker push conditions to build action

This commit is contained in:
viktorstrate 2021-03-29 12:36:14 +02:00
parent 804b4576ec
commit 1ba62ab03a
No known key found for this signature in database
GPG Key ID: 3F855605109C1E8A
1 changed files with 18 additions and 15 deletions

View File

@ -7,7 +7,7 @@ on:
branches: master
tags:
- v*
env:
DOCKER_USERNAME: viktorstrate
DOCKER_IMAGE: viktorstrate/photoview
@ -17,7 +17,7 @@ jobs:
build:
name: Build Docker Image
runs-on: ubuntu-20.04
strategy:
matrix:
target_platform:
@ -25,7 +25,7 @@ jobs:
- "linux/arm64"
- "linux/arm/v7"
- "linux/arm/v6"
steps:
- name: Checkout
uses: actions/checkout@v2
@ -51,15 +51,15 @@ jobs:
id: prepare
run: |
DOCKER_PLATFORMS=${{ matrix.target_platform }}
VERSION=edge
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
fi
OUTPUT_PLATFORM=$(echo ${{ matrix.target_platform }} | sed 's/\//-/g')
echo ::set-output name=output_platform::${OUTPUT_PLATFORM}
TAG="--tag ${DOCKER_IMAGE}:${OUTPUT_PLATFORM}-${GITHUB_SHA::8}"
echo ::set-output name=docker_username::${DOCKER_USERNAME}
@ -77,16 +77,19 @@ jobs:
- name: Docker Build
run: |
docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }}
- name: Docker Login
if: success() && github.event_name != 'pull_request' && github.repository == 'photoview/photoview'
run: |
echo "${DOCKER_PASSWORD}" | docker login --username "${{ steps.prepare.outputs.docker_username }}" --password-stdin
- name: Push to Docker Hub
if: success() && github.event_name != 'pull_request' && github.repository == 'photoview/photoview'
run: |
docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}
- name: Clear
if: always() && github.event_name != 'pull_request' && github.repository == 'photoview/photoview'
run: |
rm -f ${HOME}/.docker/config.json
@ -94,34 +97,34 @@ jobs:
name: Combine Docker Images
runs-on: ubuntu-20.04
if: github.event_name != 'pull_request' && github.repository == 'photoview/photoview'
needs: [build]
steps:
- name: Docker Login
run: |
echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin
- name: Create Manifests
run: |
DOCKER_IMAGES="${DOCKER_IMAGE}:linux-amd64-${GITHUB_SHA::8}"
DOCKER_IMAGES="${DOCKER_IMAGES} ${DOCKER_IMAGE}:linux-arm64-${GITHUB_SHA::8}"
DOCKER_IMAGES="${DOCKER_IMAGES} ${DOCKER_IMAGE}:linux-arm-v7-${GITHUB_SHA::8}"
DOCKER_IMAGES="${DOCKER_IMAGES} ${DOCKER_IMAGE}:linux-arm-v6-${GITHUB_SHA::8}"
VERSION=edge
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
fi
TAGS=("${VERSION}")
if [[ $VERSION =~ ^(([0-9]{1,3})\.[0-9]{1,3})\.[0-9]{1,3}$ ]]; then
VERSION_MINOR=${BASH_REMATCH[1]}
VERSION_MAJOR=${BASH_REMATCH[2]}
TAGS+=("${VERSION_MAJOR}", "${VERSION_MINOR}")
fi
for TAG in ${TAGS[*]}; do
echo "Creating tag: ${TAG}"
docker manifest create ${DOCKER_IMAGE}:${TAG} ${DOCKER_IMAGES}