diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9b07a8e..88d2d15 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,32 +14,25 @@ on: paths-ignore: - '**.md' +env: + DOCKERHUB_SLUG: librenms/librenms + jobs: build: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2.3.3 + uses: actions/checkout@v2.3.2 - - name: Prepare - id: prep - run: | - DOCKER_IMAGE=librenms/librenms - VERSION=edge - if [[ $GITHUB_REF == refs/tags/* ]]; then - TAG=${GITHUB_REF#refs/tags/} - VERSION=${TAG%-*} - fi - TAGS="${DOCKER_IMAGE}:${VERSION}" - if [ "$VERSION" != "edge" ]; then - TAGS="$TAGS,${DOCKER_IMAGE}:latest" - fi - echo ::set-output name=docker_image::${DOCKER_IMAGE} - echo ::set-output name=version::${VERSION} - 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: Docker meta + id: docker_meta + uses: crazy-max/ghaction-docker-meta@v1 + with: + images: ${{ env.DOCKERHUB_SLUG }} + tag-edge: true + tag-match: (.*)-RC + tag-match-group: 1 - name: Set up QEMU uses: docker/setup-qemu-action@v1 @@ -51,7 +44,7 @@ jobs: - name: Login to DockerHub if: github.event_name != 'pull_request' - uses: docker/login-action@v1.6.0 + uses: docker/login-action@v1.3.0 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} @@ -62,19 +55,21 @@ jobs: 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 }} + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.docker_meta.outputs.tags }} + labels: | + ${{ steps.docker_meta.outputs.labels }} + org.opencontainers.image.title=LibreNMS + org.opencontainers.image.description=Fully featured network monitoring system + org.opencontainers.image.vendor=CrazyMax - name: Check manifest - if: github.event_name != 'pull_request' && (endsWith(github.ref, github.event.repository.default_branch) || startsWith(github.ref, 'refs/tags/')) + if: github.event_name != 'pull_request' run: | - docker buildx imagetools inspect ${{ steps.prep.outputs.docker_image }}:${{ steps.prep.outputs.version }} + docker buildx imagetools inspect ${{ env.DOCKERHUB_SLUG }}:${{ steps.docker_meta.outputs.version }} - - name: Check pull - if: github.event_name != 'pull_request' && (endsWith(github.ref, github.event.repository.default_branch) || startsWith(github.ref, 'refs/tags/')) + name: Inspect + if: github.event_name != 'pull_request' run: | - docker pull ${{ steps.prep.outputs.docker_image }}:${{ steps.prep.outputs.version }} + docker pull ${{ env.DOCKERHUB_SLUG }}:${{ steps.docker_meta.outputs.version }} + docker image inspect ${{ env.DOCKERHUB_SLUG }}:${{ steps.docker_meta.outputs.version }}