metadata-action/.github/workflows/ci.yml

264 lines
6.3 KiB
YAML
Raw Permalink Normal View History

2020-10-25 10:21:46 +08:00
name: ci
on:
schedule:
2020-10-27 00:54:22 +08:00
- cron: '0 */4 * * *' # every 4 hours
2020-10-25 10:21:46 +08:00
push:
branches:
- 'master'
- 'releases/v*'
2020-10-25 10:21:46 +08:00
tags:
- 'v*.*.*'
pull_request:
branches:
- 'master'
- 'releases/v*'
2020-10-25 10:21:46 +08:00
env:
DOCKER_IMAGE: localhost:5000/name/app
jobs:
multi-images:
runs-on: ubuntu-latest
steps:
-
name: Checkout
2020-11-08 09:54:03 +08:00
uses: actions/checkout@v2
2020-10-25 10:21:46 +08:00
-
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
2020-10-25 10:21:46 +08:00
tag-schedule:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
tag-schedule:
- ""
- "cron-{{date 'YYYYMMDD'}}"
- "{{date 'YYYYMMDD-HHmmss'}}"
- "schedule"
steps:
-
name: Checkout
2020-11-08 09:54:03 +08:00
uses: actions/checkout@v2
-
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
2020-10-27 08:05:36 +08:00
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
2020-11-08 09:54:03 +08:00
uses: actions/checkout@v2
-
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
2020-11-18 07:32:35 +08:00
tag-semver:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
flavor-latest:
- "auto"
- "true"
- "false"
steps:
-
name: Checkout
uses: actions/checkout@v2
-
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
2020-11-18 07:32:35 +08:00
steps:
-
name: Checkout
2020-11-18 07:32:35 +08:00
uses: actions/checkout@v2
-
name: Docker meta
2020-11-18 07:32:35 +08:00
uses: ./
with:
images: |
${{ env.DOCKER_IMAGE }}
ghcr.io/name/app
flavor: |
prefix=foo-
suffix=-bar
2020-11-18 07:32:35 +08:00
labels:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
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=Another description
org.opencontainers.image.vendor=MyCompany
2020-10-25 10:21:46 +08:00
docker-push:
runs-on: ubuntu-latest
services:
registry:
image: registry:2
ports:
- 5000:5000
steps:
-
name: Checkout
2020-11-08 09:54:03 +08:00
uses: actions/checkout@v2
2020-10-25 10:21:46 +08:00
-
name: Docker meta
id: docker_meta
uses: ./
with:
2020-10-27 08:05:36 +08:00
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
2020-10-25 10:21:46 +08:00
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
driver-opts: network=host
-
name: Build and push to local registry
uses: docker/build-push-action@v2
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@v2
-
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@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Build
2021-02-10 03:54:44 +08:00
uses: docker/bake-action@v1
with:
files: |
./test/docker-bake.hcl
${{ steps.docker_meta.outputs.bake-file }}
targets: |
release