2020-08-09 21:13:25 +02:00
|
|
|
name: Docker builds
|
2020-08-09 20:32:02 +02:00
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
branches: master
|
|
|
|
push:
|
|
|
|
branches: master
|
|
|
|
tags:
|
|
|
|
- v*
|
2021-03-28 23:03:42 +02:00
|
|
|
|
|
|
|
env:
|
|
|
|
DOCKER_USERNAME: viktorstrate
|
|
|
|
DOCKER_IMAGE: viktorstrate/photoview
|
|
|
|
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
2020-08-09 20:32:02 +02:00
|
|
|
|
|
|
|
jobs:
|
2020-08-09 21:13:25 +02:00
|
|
|
build:
|
2021-03-28 21:24:32 +02:00
|
|
|
name: Build Docker Image
|
2021-02-16 10:44:38 +01:00
|
|
|
runs-on: ubuntu-20.04
|
2021-03-28 19:39:22 +02:00
|
|
|
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
target_platform:
|
|
|
|
- "linux/amd64"
|
|
|
|
- "linux/arm64"
|
2021-03-28 23:03:42 +02:00
|
|
|
- "linux/arm/v7"
|
|
|
|
- "linux/arm/v6"
|
2021-03-28 19:39:22 +02:00
|
|
|
|
2020-08-09 20:32:02 +02:00
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v2
|
2020-08-09 21:13:25 +02:00
|
|
|
|
|
|
|
- name: Cache Docker layers
|
|
|
|
uses: actions/cache@v2
|
|
|
|
id: cache
|
|
|
|
with:
|
|
|
|
path: /tmp/.buildx-cache
|
2021-03-28 19:39:22 +02:00
|
|
|
key: ${{ runner.os }}-buildx-${{ secrets.CACHE_KEY }}-${{ matrix.target_platform }}-${{ github.sha }}
|
2021-03-28 19:27:25 +02:00
|
|
|
restore-keys: |
|
2021-03-28 19:39:22 +02:00
|
|
|
${{ runner.os }}-buildx-${{ secrets.CACHE_KEY }}-${{ matrix.target_platform }}-
|
2020-08-09 21:13:25 +02:00
|
|
|
|
2020-12-09 19:24:39 +01:00
|
|
|
- name: Set up QEMU
|
|
|
|
uses: docker/setup-qemu-action@v1
|
|
|
|
with:
|
2021-03-28 19:39:22 +02:00
|
|
|
platforms: ${{ matrix.target_platform }}
|
2020-12-09 19:24:39 +01:00
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
|
2020-08-09 20:32:02 +02:00
|
|
|
- name: Prepare
|
|
|
|
id: prepare
|
|
|
|
run: |
|
2021-03-28 19:39:22 +02:00
|
|
|
DOCKER_PLATFORMS=${{ matrix.target_platform }}
|
2021-03-28 23:32:41 +02:00
|
|
|
|
2020-08-09 20:32:02 +02:00
|
|
|
VERSION=edge
|
|
|
|
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
|
|
|
VERSION=${GITHUB_REF#refs/tags/v}
|
|
|
|
fi
|
2021-03-28 23:03:42 +02:00
|
|
|
|
|
|
|
OUTPUT_PLATFORM=$(echo ${{ matrix.target_platform }} | sed 's/\//-/g')
|
|
|
|
echo ::set-output name=output_platform::${OUTPUT_PLATFORM}
|
|
|
|
|
2021-03-28 23:11:00 +02:00
|
|
|
TAG="--tag ${DOCKER_IMAGE}:${OUTPUT_PLATFORM}-${GITHUB_SHA::8}"
|
2020-08-09 20:32:02 +02:00
|
|
|
|
|
|
|
echo ::set-output name=docker_username::${DOCKER_USERNAME}
|
|
|
|
echo ::set-output name=docker_image::${DOCKER_IMAGE}
|
|
|
|
echo ::set-output name=version::${VERSION}
|
|
|
|
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \
|
2020-12-09 19:24:39 +01:00
|
|
|
--progress=plain \
|
2020-08-09 21:13:25 +02:00
|
|
|
--cache-from "type=local,src=/tmp/.buildx-cache" \
|
|
|
|
--cache-to "type=local,dest=/tmp/.buildx-cache" \
|
2020-08-09 20:32:02 +02:00
|
|
|
--build-arg VERSION=${VERSION} \
|
|
|
|
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
|
|
|
|
--build-arg VCS_REF=${GITHUB_SHA::8} \
|
2021-03-28 23:03:42 +02:00
|
|
|
${TAG} --file Dockerfile .
|
2020-08-09 21:13:25 +02:00
|
|
|
|
2021-03-28 21:24:32 +02:00
|
|
|
- name: Docker Build
|
2020-08-09 20:32:02 +02:00
|
|
|
run: |
|
2021-03-28 23:07:06 +02:00
|
|
|
docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }}
|
2021-03-28 21:24:32 +02:00
|
|
|
|
2021-03-28 23:03:42 +02:00
|
|
|
- name: Docker Login
|
|
|
|
run: |
|
|
|
|
echo "${DOCKER_PASSWORD}" | docker login --username "${{ steps.prepare.outputs.docker_username }}" --password-stdin
|
2020-08-09 21:13:25 +02:00
|
|
|
|
2021-03-28 23:03:42 +02:00
|
|
|
- name: Push to Docker Hub
|
|
|
|
run: |
|
|
|
|
docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}
|
|
|
|
|
|
|
|
- name: Clear
|
|
|
|
run: |
|
|
|
|
rm -f ${HOME}/.docker/config.json
|
|
|
|
|
|
|
|
docker-manifest:
|
|
|
|
name: Combine Docker Images
|
2021-03-28 21:24:32 +02:00
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
if: github.event_name != 'pull_request' && github.repository == 'photoview/photoview'
|
|
|
|
|
|
|
|
needs: [build]
|
2021-03-28 23:03:42 +02:00
|
|
|
|
2021-03-28 21:24:32 +02:00
|
|
|
steps:
|
2021-03-28 23:03:42 +02:00
|
|
|
- name: Docker Login
|
|
|
|
run: |
|
2021-03-28 23:15:42 +02:00
|
|
|
echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin
|
2021-03-28 21:24:32 +02:00
|
|
|
|
2021-03-28 23:32:41 +02:00
|
|
|
- name: Create Manifests
|
2020-08-09 20:32:02 +02:00
|
|
|
run: |
|
2021-03-28 23:15:42 +02:00
|
|
|
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}"
|
2021-03-28 23:03:42 +02:00
|
|
|
|
2021-03-28 23:32:41 +02:00
|
|
|
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}
|
|
|
|
docker manifest push ${DOCKER_IMAGE}:${TAG}
|
|
|
|
done
|