changing image name defaults (#4)

This commit is contained in:
Bret Fisher
2022-05-17 17:21:36 -04:00
committed by GitHub
parent 8faa369836
commit e88f98ccbf
3 changed files with 15 additions and 58 deletions

View File

@@ -8,12 +8,10 @@ on:
push: push:
branches: branches:
- main - main
# don't rebuild image if someone only edited unrelated files
paths-ignore: paths-ignore:
- 'README.md' - 'README.md'
- '.github/linters/**' - '.github/linters/**'
pull_request: pull_request:
# don't rebuild image if someone only edited unrelated files
paths-ignore: paths-ignore:
- 'README.md' - 'README.md'
- '.github/linters/**' - '.github/linters/**'
@@ -27,57 +25,20 @@ jobs:
permissions: permissions:
contents: read contents: read
packages: write # needed to push docker image to ghcr.io packages: write
pull-requests: write # needed to create and update comments in PRs pull-requests: write
secrets: secrets:
# Only needed if with:dockerhub-enable is true below
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }}
# Only needed if with:dockerhub-enable is true below
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}
with: 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 dockerhub-enable: true
ghcr-enable: true ghcr-enable: true
### REQUIRED
### A list of the account/repo names for docker build. List should match what's enabled above
### defaults to:
image-names: | image-names: |
${{ github.repository }} ${{ github.repository }}
ghcr.io/${{ github.repository }} ghcr.io/${{ github.repository }}
### REQUIRED 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=ref,event=pr
type=ref,event=branch
type=semver,pattern={{version}}
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
### build stage to target, defaults to empty, which builds to last stage in Dockerfile
# target:
### platforms to build for, defaults to linux/amd64
### other options: linux/amd64,linux/arm64,linux/arm/v7
# platforms: linux/amd64
### Create a PR comment with image tags and labels
### defaults to false
# comment-enable: false

View File

@@ -26,7 +26,7 @@ on:
comment-enable: comment-enable:
description: Create a PR comment with image tags and labels description: Create a PR comment with image tags and labels
required: false required: false
default: false default: true
type: boolean type: boolean
context: context:
description: Docker context (path) to start build from description: Docker context (path) to start build from
@@ -47,11 +47,13 @@ on:
type: string type: string
# common ones: linux/amd64,linux/arm64,linux/arm/v7 # common ones: linux/amd64,linux/arm64,linux/arm/v7
default: linux/amd64 default: linux/amd64
# TODO: does this work in calling repos?
image-names: image-names:
description: A list of the account/repo names for docker build description: A list of the account/repo names for docker build
required: true required: false
type: string type: string
default: |
${{ github.repository }}
ghcr.io/${{ github.repository }}
tag-rules: tag-rules:
# https://github.com/marketplace/actions/docker-metadata-action#tags-input # https://github.com/marketplace/actions/docker-metadata-action#tags-input
description: Use docker-metadata action to create tags from a key-value pair list in CSV format description: Use docker-metadata action to create tags from a key-value pair list in CSV format
@@ -80,9 +82,6 @@ on:
required: false required: false
outputs: outputs:
image-tags:
description: "all tags from docker build"
value: ${{ jobs.build-image.outputs.image-tags }}
ghcr-tag: ghcr-tag:
description: "single-use tag for ghcr.io" description: "single-use tag for ghcr.io"
value: ${{ jobs.build-image.outputs.ghcr-tag }} value: ${{ jobs.build-image.outputs.ghcr-tag }}
@@ -105,8 +104,6 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
# all tags from docker build
image-tags: ${{ steps.docker_meta.outputs.tags }}
# only outputs the unique gha- image tag that's unique to each build # only outputs the unique gha- image tag that's unique to each build
ghcr-tag: ${{ steps.ghcr-tag.outputs.tag }} ghcr-tag: ${{ steps.ghcr-tag.outputs.tag }}

View File

@@ -30,11 +30,9 @@ jobs:
secrets: secrets:
# Only needed if with:dockerhub-enable is true below
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }}
# Only needed if with:dockerhub-enable is true below # Only needed if with:dockerhub-enable is true below
# https://hub.docker.com/settings/security # https://hub.docker.com/settings/security
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}
with: with:
@@ -46,11 +44,11 @@ jobs:
dockerhub-enable: true dockerhub-enable: true
ghcr-enable: true ghcr-enable: true
### REQUIRED
### A list of the account/repo names for docker build. List should match what's enabled above ### A list of the account/repo names for docker build. List should match what's enabled above
### defaults to: ### defaults to:
image-names: | # image-names: |
ghcr.io/${{ github.repository }} # ${{ github.repository }}
# ghcr.io/${{ github.repository }}
### set rules for tagging images, based on special action syntax: ### set rules for tagging images, based on special action syntax:
### https://github.com/docker/metadata-action#tags-input ### https://github.com/docker/metadata-action#tags-input
@@ -72,10 +70,11 @@ jobs:
### build stage to target, defaults to empty, which builds to last stage in Dockerfile ### build stage to target, defaults to empty, which builds to last stage in Dockerfile
# target: # target:
### platforms to build for, defaults to linux/amd64 ### platforms to build for
### defaults to linux/amd64
### other options: linux/amd64,linux/arm64,linux/arm/v7 ### other options: linux/amd64,linux/arm64,linux/arm/v7
# platforms: linux/amd64 # platforms: linux/amd64,linux/arm64
### Create a PR comment with image tags and labels ### Create a PR comment with image tags and labels
### defaults to false ### defaults to true
# comment-enable: false # comment-enable: false