1
0
Fork 0
mirror of https://github.com/librenms/docker.git synced 2026-01-23 10:15:22 +00:00

Switch to Docker actions

This commit is contained in:
CrazyMax 2020-09-10 00:09:11 +02:00
parent f68d1b28b8
commit 626b9ee479
No known key found for this signature in database
GPG key ID: 3248E46B6BB8C7F7

View file

@ -23,49 +23,51 @@ jobs:
uses: actions/checkout@v2.3.2
-
name: Prepare
id: prepare
id: prep
run: |
DOCKER_IMAGE=librenms/librenms
DOCKER_PLATFORMS=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le,linux/s390x
VERSION=edge
if [[ $GITHUB_REF == refs/tags/* ]]; then
TAG=${GITHUB_REF#refs/tags/}
VERSION=${TAG%-*}
fi
TAGS="--tag ${DOCKER_IMAGE}:${VERSION}"
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [ "$VERSION" != "edge" ]; then
TAGS="$TAGS --tag ${DOCKER_IMAGE}:latest"
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
fi
echo ::set-output name=docker_image::${DOCKER_IMAGE}
echo ::set-output name=version::${VERSION}
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \
--build-arg VERSION=${VERSION} \
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
--build-arg VCS_REF=${GITHUB_SHA::8} \
${TAGS} --file Dockerfile .
echo ::set-output name=tags::${TAGS}
echo ::set-output name=build_date::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
echo ::set-output name=vcs_ref::${GITHUB_SHA::8}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: crazy-max/ghaction-docker-buildx@v3.3.0
uses: docker/setup-buildx-action@v1
-
name: Docker Buildx (build)
run: |
docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }}
- name: Login to DockerHub
if: success() && github.event_name != 'pull_request' && (endsWith(github.ref, github.event.repository.default_branch) || startsWith(github.ref, 'refs/tags/'))
name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v1.3.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Docker Buildx (push)
if: success() && github.event_name != 'pull_request' && (endsWith(github.ref, github.event.repository.default_branch) || startsWith(github.ref, 'refs/tags/'))
run: |
docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}
name: Build
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le,linux/s390x
push: ${{ github.event_name != 'pull_request' && (endsWith(github.ref, github.event.repository.default_branch) || startsWith(github.ref, 'refs/tags/')) }}
tags: ${{ steps.prep.outputs.tags }}
build-args: |
VERSION=${{ steps.prep.outputs.version }}
BUILD_DATE=${{ steps.prep.outputs.build_date }}
VCS_REF=${{ steps.prep.outputs.vcs_ref }}
-
name: Docker Check Manifest
name: Check manifest
if: success() && github.event_name != 'pull_request' && (endsWith(github.ref, github.event.repository.default_branch) || startsWith(github.ref, 'refs/tags/'))
run: |
docker buildx imagetools inspect ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}
docker buildx imagetools inspect ${{ steps.prep.outputs.docker_image }}:${{ steps.prep.outputs.version }}