Adding more advanced workflows (#25)

This commit is contained in:
Bret Fisher
2023-04-05 18:18:02 -04:00
committed by GitHub
parent e1b1573ef9
commit 6702a1ebf8
6 changed files with 222 additions and 81 deletions

View File

@@ -0,0 +1,69 @@
---
# template source: https://github.com/bretfisher/docker-build-workflow/blob/main/templates/call-docker-build-promote.yaml
name: Docker Build
on:
push:
branches:
- main
# don't rebuild image if someone only edited unrelated files
paths-ignore:
- 'README.md'
- '.github/linters/**'
pull_request:
# don't rebuild image if someone only edited unrelated files
paths-ignore:
- 'README.md'
- '.github/linters/**'
# cancel any previously-started, yet still active runs of this workflow on the same branch
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
permissions:
contents: read
packages: write # needed to push docker image to ghcr.io
pull-requests: write # needed to create and update comments in PRs
jobs:
# run this job on every push to a PR
# it will push images to GHCR, but not DockerHub
docker-build-pr:
name: Call Build on PR
if: github.event_name == 'pull_request'
# FIXME: fork this repo and update this path to YOUR reusable workflow location
uses: bretfisher/docker-build-workflow/.github/workflows/reusable-docker-build.yaml@main
with:
# NOTE: there are lots of input options for this reusable workflow
# read the comments in the inputs area of the reusable workflow for more info
# https://github.com/BretFisher/docker-build-workflow/blob/main/.github/workflows/reusable-docker-build.yaml
dockerhub-enable: false
ghcr-enable: true
push: true
image-names: |
ghcr.io/${{ github.repository }}
# run this job on every push to the default branch (including merges and tags)
# it will push images to GHCR and DockerHub
# tags will also include ones like `stable-<date>-<sha>` and `latest`
docker-build-merge:
name: Call Build on Push
# this if is filtered to only the main branch push event (see events at top)
if: github.event_name == 'push'
# FIXME: fork this repo and update this path to YOUR reusable workflow location
uses: bretfisher/docker-build-workflow/.github/workflows/reusable-docker-build.yaml@main
secrets:
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}
with:
# NOTE: there are lots of input options for this reusable workflow
# read the comments in the inputs area of the reusable workflow for more info
# https://github.com/BretFisher/docker-build-workflow/blob/main/.github/workflows/reusable-docker-build.yaml
dockerhub-enable: true
ghcr-enable: true
push: true
image-names: |
docker.io/${{ github.repository }}
ghcr.io/${{ github.repository }}

View File

@@ -26,6 +26,7 @@ jobs:
name: Call Docker Build
# FIXME: fork this repo and update this path to YOUR reusable workflow location
uses: bretfisher/docker-build-workflow/.github/workflows/reusable-docker-build.yaml@main
permissions:
@@ -37,49 +38,34 @@ jobs:
# Only needed if with:dockerhub-enable is true below
# https://hub.docker.com/settings/security
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}
# dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }}
# dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}
with:
### REQUIRED
### ENABLE ONE OR BOTH REGISTRIES
### tell docker where to push.
### NOTE if Docker Hub is set to true, you must set secrets above and also add account/repo/tags below
dockerhub-enable: true
ghcr-enable: true
# NOTE: there are lots of input options for this reusable workflow
# read the comments in the inputs area of the reusable workflow for more info
# https://github.com/BretFisher/docker-build-workflow/blob/main/.github/workflows/reusable-docker-build.yaml
# Here are just a few of the common defaults
# dockerhub-enable: false
# ghcr-enable: true
### A list of the account/repo names for docker build. List should match what's enabled above
### defaults to:
# image-names: |
# ${{ github.repository }}
# ghcr.io/${{ github.repository }}
### set rules for tagging images, based on special action syntax:
### https://github.com/docker/metadata-action#tags-input
### defaults to:
#tag-rules: |
# type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
# type=raw,value=stable-{{date 'YYYYMMDDHHmmss'}},enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
# type=ref,event=pr
# type=ref,event=branch
# type=raw,value=gha-${{ github.run_id }}
### path to where docker should copy files into image
### defaults to root of repository (.)
# context: .
### Dockerfile alternate name. Default is Dockerfile (relative to context path)
# file: Containerfile
# tag-rules: |
# type=raw,value=stable-{{date 'YYYYMMDD'}}-{{sha}},enable={{is_default_branch}},priority=300
# type=ref,event=tag,priority=200
# type=raw,value=latest,enable={{is_default_branch}},priority=100
# type=raw,value=gha-${{ github.run_id }},enable=${{github.event_name == 'pull_request'}},priority=200
# type=ref,event=pr,priority=100
### build stage to target, defaults to empty, which builds to last stage in Dockerfile
# context: "{{defaultContext}}"
# target:
### platforms to build for
### defaults to linux/amd64
### other options: linux/amd64,linux/arm64,linux/arm/v7
# platforms: linux/amd64,linux/arm64
# platforms: linux/amd64
### Create a PR comment with image tags and labels
### defaults to true
# comment-enable: false
# comment-enable: true