Skip to content

Publish docker images #1246

Publish docker images

Publish docker images #1246

# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Publish docker images
on:
schedule:
- cron: '0 0 * * *' # each 12:00 UTC
push:
branches: [ main ]
tags: [ 'v*.*.*' ] # semver release
pull_request:
branches: [ main ]
env:
REGISTRY: ghcr.io
jobs:
build_containers:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
include:
- image: ${{github.repository_owner}}/registry-authz-server
context: "."
dockerfile: "containers/registry-authz-server/Dockerfile"
- image: ${{github.repository_owner}}/registry-spec-renderer
context: "containers/registry-spec-renderer"
dockerfile: "containers/registry-spec-renderer/Dockerfile"
- image: ${{github.repository_owner}}/registry-prism-mock-server
context: "containers/registry-mock-server/openapi"
dockerfile: containers/registry-mock-server/openapi/Dockerfile
- image: ${{github.repository_owner}}/registry-graphql-mock-server
context: "containers/registry-mock-server/graphql"
dockerfile: containers/registry-mock-server/graphql/Dockerfile
- image: ${{github.repository_owner}}/registry-linters
context: "."
dockerfile: "containers/registry-linters/Dockerfile"
- image: ${{github.repository_owner}}/registry-protoc-gen-doc
context: "containers/registry-protoc-gen-doc"
dockerfile: "containers/registry-protoc-gen-doc/Dockerfile"
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ matrix.image }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push ${{ env.REGISTRY }}/${{ matrix.image }} Docker image
uses: docker/build-push-action@v4
with:
context: ${{ matrix.context }}
file: ${{ matrix.dockerfile }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}