Merge pull request #59 from adamus1red/adamus1red-docker-ci-tweaks

Update GHA CI to use offical docker build/push actions and allow PR's to be tested
This commit is contained in:
Timothy Miller 2021-10-29 21:52:31 -04:00 committed by GitHub
commit 870da367a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@ name: Build cloudflare-ddns Docker image (multi-arch)
on: on:
push: push:
branches: master branches: master
pull_request:
jobs: jobs:
build: build:
@ -17,9 +18,37 @@ jobs:
- name: Setting up Docker Buildx - name: Setting up Docker Buildx
uses: docker/setup-buildx-action@v1 uses: docker/setup-buildx-action@v1
- name: Login to DockerHub - name: Login to DockerHub
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin if: github.event_name != 'pull_request'
- name: Build & Publish to DockerHub uses: docker/login-action@v1
run: | with:
docker buildx build \ username: ${{ secrets.DOCKER_USERNAME }}
--tag timothyjmiller/cloudflare-ddns:latest \ password: ${{ secrets.DOCKER_PASSWORD }}
--platform linux/ppc64le,linux/s390x,linux/386,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/amd64 . --push
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: timothyjmiller/cloudflare-ddns
sep-tags: ','
flavor: |
latest=false
tags: |
type=raw,enable=${{ steps.extract_branch.outputs.branch == 'master' }},value=latest
type=schedule
type=ref,event=pr
- name: Build and publish
uses: docker/build-push-action@v2
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/ppc64le,linux/s390x,linux/386,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/amd64
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.created=${{ steps.meta.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}