Skip to content

Commit

Permalink
Changes to enable workflow dispatch for 'build' github action (pglomb…
Browse files Browse the repository at this point in the history
…ardo#1446)

* reenable manual build workflow
and minor fixes

* enbale sha tagging for worklow_dispatch only
  • Loading branch information
sirux88 authored Oct 3, 2023
1 parent 8b411e7 commit caf234e
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions .github/workflows/docker-containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@ on:
- "v*.*.*"

workflow_dispatch:

inputs:
dockerPush:
description: 'Push image to docker hub?'
required: true
type: boolean
default: false
schedule:
# * is a special character in YAML so you have to quote this string
# Run every day at 5:24 UTC - build 'latest' docker containers
- cron: "24 17 * * *"

env:
DOCKER_PUSH: true
jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -35,11 +41,15 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Set DOCKER_PUSH for workflow_dispatch
if: ${{ github.event_name == 'workflow_dispatch' }}
run: echo "DOCKER_PUSH=${{ github.event.inputs.dockerPush }}" >> $GITHUB_ENV

- name: Populate Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: pglombardo/pwpush-${{ matrix.dbType }}
images: ${{ secrets.DOCKER_USERNAME }}/pwpush-${{ matrix.dbType }}
flavor: |
latest=false
tags: |
Expand All @@ -49,9 +59,11 @@ jobs:
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=semver,pattern=latest
type=sha,enable=${{ github.event_name == 'workflow_dispatch' }}
- name: Login to DockerHub
uses: docker/login-action@v3
if: ${{env.DOCKER_PUSH == 'true'}}
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
Expand All @@ -62,8 +74,8 @@ jobs:
file: ./containers/docker/pwpush-${{ matrix.dbType }}/Dockerfile
platforms: linux/amd64,linux/arm64
provenance: false
push: true
push: ${{env.DOCKER_PUSH == 'true'}}
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=registry,ref=${{ secrets.DOCKER_USERNAME }}/pwpush-${{ matrix.dbType }}:buildcache
cache-to: type=registry,ref=${{ secrets.DOCKER_USERNAME }}/pwpush-${{ matrix.dbType }}:buildcache,mode=max
cache-to: type=registry,ref=${{ secrets.DOCKER_USERNAME }}/pwpush-${{ matrix.dbType }}:buildcache,mode=max,ignore-error=${{env.DOCKER_PUSH == 'false'}}

0 comments on commit caf234e

Please sign in to comment.