mirror of
https://github.com/docker/metadata-action.git
synced 2024-11-04 19:25:40 +01:00
59267481d9
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
325 lines
8.1 KiB
YAML
325 lines
8.1 KiB
YAML
name: ci
|
|
|
|
on:
|
|
schedule:
|
|
- cron: '0 */4 * * *' # every 4 hours
|
|
push:
|
|
branches:
|
|
- 'master'
|
|
- 'releases/v*'
|
|
tags:
|
|
- 'v*.*.*'
|
|
pull_request:
|
|
branches:
|
|
- 'master'
|
|
- 'releases/v*'
|
|
|
|
env:
|
|
DOCKER_IMAGE: localhost:5000/name/app
|
|
|
|
jobs:
|
|
multi-images:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
-
|
|
name: Checkout
|
|
uses: actions/checkout@v3
|
|
-
|
|
name: Docker meta
|
|
uses: ./
|
|
with:
|
|
images: |
|
|
${{ env.DOCKER_IMAGE }}
|
|
ghcr.io/name/app
|
|
tags: |
|
|
type=schedule
|
|
type=ref,event=branch
|
|
type=ref,event=tag
|
|
type=ref,event=pr
|
|
type=sha
|
|
|
|
tag-schedule:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
tag-schedule:
|
|
- ""
|
|
- "cron-{{date 'YYYYMMDD'}}"
|
|
- "{{date 'YYYYMMDD-HHmmss'}}"
|
|
- "schedule"
|
|
steps:
|
|
-
|
|
name: Checkout
|
|
uses: actions/checkout@v3
|
|
-
|
|
name: Docker meta
|
|
uses: ./
|
|
with:
|
|
images: |
|
|
${{ env.DOCKER_IMAGE }}
|
|
ghcr.io/name/app
|
|
tags: |
|
|
type=schedule,pattern=${{ matrix.tag-schedule }}
|
|
type=ref,event=branch
|
|
type=ref,event=tag
|
|
type=ref,event=pr
|
|
type=sha
|
|
|
|
tag-match:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- tag-match: '\d.\d.\d'
|
|
tag-match-group: '0'
|
|
- tag-match: '\d.\d'
|
|
tag-match-group: '0'
|
|
- tag-match: 'v(.*)'
|
|
tag-match-group: '1'
|
|
steps:
|
|
-
|
|
name: Checkout
|
|
uses: actions/checkout@v3
|
|
-
|
|
name: Docker meta
|
|
uses: ./
|
|
with:
|
|
images: |
|
|
${{ env.DOCKER_IMAGE }}
|
|
ghcr.io/name/app
|
|
tags: |
|
|
type=schedule
|
|
type=ref,event=branch
|
|
type=ref,event=tag
|
|
type=ref,event=pr
|
|
type=match,"pattern=${{ matrix.tag-match }}",group=${{ matrix.tag-match-group }}
|
|
type=sha
|
|
|
|
tag-semver:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
flavor-latest:
|
|
- "auto"
|
|
- "true"
|
|
- "false"
|
|
steps:
|
|
-
|
|
name: Checkout
|
|
uses: actions/checkout@v3
|
|
-
|
|
name: Docker meta
|
|
uses: ./
|
|
with:
|
|
images: |
|
|
${{ env.DOCKER_IMAGE }}
|
|
ghcr.io/name/app
|
|
tags: |
|
|
type=schedule
|
|
type=ref,event=branch
|
|
type=ref,event=tag
|
|
type=ref,event=pr
|
|
type=semver,pattern={{raw}}
|
|
type=semver,pattern={{version}}
|
|
type=semver,pattern={{major}}.{{minor}}.{{patch}}
|
|
type=sha
|
|
flavor: |
|
|
latest=${{ matrix.flavor-latest }}
|
|
|
|
flavor:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
-
|
|
name: Checkout
|
|
uses: actions/checkout@v3
|
|
-
|
|
name: Docker meta
|
|
uses: ./
|
|
with:
|
|
images: |
|
|
${{ env.DOCKER_IMAGE }}
|
|
ghcr.io/name/app
|
|
flavor: |
|
|
prefix=foo-
|
|
suffix=-bar
|
|
|
|
images:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
-
|
|
name: Checkout
|
|
uses: actions/checkout@v3
|
|
-
|
|
name: Docker meta
|
|
uses: ./
|
|
with:
|
|
images: |
|
|
name=${{ env.DOCKER_IMAGE }}
|
|
name=ghcr.io/name/app,enable=${{ github.event_name == 'pull_request' }}
|
|
name=ghcr.io/name/release,enable=${{ startsWith(github.ref, 'refs/tags/') }}
|
|
|
|
labels:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
-
|
|
name: Checkout
|
|
uses: actions/checkout@v3
|
|
-
|
|
name: Docker meta
|
|
uses: ./
|
|
with:
|
|
images: |
|
|
${{ env.DOCKER_IMAGE }}
|
|
ghcr.io/name/app
|
|
labels: |
|
|
maintainer=CrazyMax
|
|
org.opencontainers.image.title=MyCustomTitle
|
|
org.opencontainers.image.description=this is a "good" example
|
|
org.opencontainers.image.vendor=MyCompany
|
|
|
|
global-exps:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
-
|
|
name: Checkout
|
|
uses: actions/checkout@v3
|
|
-
|
|
name: Docker meta
|
|
uses: ./
|
|
with:
|
|
images: |
|
|
${{ env.DOCKER_IMAGE }}
|
|
ghcr.io/name/app
|
|
tags: |
|
|
type=sha
|
|
type=raw,value=gexp-branch-{{branch}}
|
|
type=raw,value=gexp-date-{{date 'YYYYMMDD'}}
|
|
type=raw,value=gexp-tag-{{tag}}
|
|
type=raw,value=gexp-baseref-{{base_ref}}
|
|
type=raw,value=gexp-defbranch,enable={{is_default_branch}}
|
|
|
|
json:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
-
|
|
name: Checkout
|
|
uses: actions/checkout@v3
|
|
-
|
|
name: Docker meta
|
|
id: meta
|
|
uses: ./
|
|
with:
|
|
images: |
|
|
${{ env.DOCKER_IMAGE }}
|
|
ghcr.io/name/app
|
|
labels: |
|
|
maintainer=CrazyMax
|
|
-
|
|
name: JSON output
|
|
run: |
|
|
echo "maintainer=${{ fromJSON(steps.meta.outputs.json).labels['maintainer'] }}"
|
|
echo "version=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}"
|
|
echo "revision=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}"
|
|
echo "created=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}"
|
|
|
|
docker-push:
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
registry:
|
|
image: registry:2
|
|
ports:
|
|
- 5000:5000
|
|
steps:
|
|
-
|
|
name: Checkout
|
|
uses: actions/checkout@v3
|
|
-
|
|
name: Docker meta
|
|
id: docker_meta
|
|
uses: ./
|
|
with:
|
|
images: |
|
|
${{ env.DOCKER_IMAGE }}
|
|
tags: |
|
|
type=schedule
|
|
type=ref,event=branch
|
|
type=ref,event=tag
|
|
type=ref,event=pr
|
|
type=semver,pattern=v{{version}}
|
|
type=semver,pattern=v{{major}}.{{minor}}
|
|
type=semver,pattern=v{{major}}
|
|
type=sha
|
|
-
|
|
name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v2
|
|
-
|
|
name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
with:
|
|
driver-opts: network=host
|
|
-
|
|
name: Build and push to local registry
|
|
uses: docker/build-push-action@v3
|
|
with:
|
|
context: ./test
|
|
file: ./test/Dockerfile
|
|
platforms: linux/amd64,linux/arm64,linux/386
|
|
push: true
|
|
tags: ${{ steps.docker_meta.outputs.tags }}
|
|
labels: ${{ steps.docker_meta.outputs.labels }}
|
|
-
|
|
name: Inspect image
|
|
run: |
|
|
docker pull ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }}
|
|
docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }}
|
|
-
|
|
name: Check manifest
|
|
run: |
|
|
docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }}
|
|
-
|
|
name: Dump context
|
|
if: always()
|
|
uses: crazy-max/ghaction-dump-context@v1
|
|
|
|
bake:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
-
|
|
name: Checkout
|
|
uses: actions/checkout@v3
|
|
-
|
|
name: Docker meta
|
|
id: docker_meta
|
|
uses: ./
|
|
with:
|
|
images: |
|
|
${{ env.DOCKER_IMAGE }}
|
|
ghcr.io/name/app
|
|
tags: |
|
|
type=schedule
|
|
type=ref,event=branch
|
|
type=ref,event=tag
|
|
type=ref,event=pr
|
|
type=semver,pattern={{version}}
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
type=semver,pattern={{major}}
|
|
type=sha
|
|
-
|
|
name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v2
|
|
-
|
|
name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
-
|
|
name: Build
|
|
uses: docker/bake-action@v2
|
|
with:
|
|
files: |
|
|
./test/docker-bake.hcl
|
|
${{ steps.docker_meta.outputs.bake-file }}
|
|
targets: |
|
|
release
|