Skip to content

add tags to JobArtifact (#625) #150

add tags to JobArtifact (#625)

add tags to JobArtifact (#625) #150

name: "Publish Docker images to Docker Registry"
on:
pull_request:
paths:
- ./mantis-control-plane/mantis-control-plane-server/build.gradle
- ./mantis-server/mantis-server-agent/build.gradle
- ./mantis-examples/mantis-examples-mantis-publish-sample/build.gradle
- .github/workflows/push-docker-image.yml
push:
tags:
- v*.*.*
- v*.*.*-rc.*
release:
types:
- published
jobs:
build-and-push-image:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- dockerfile: ./mantis-control-plane/mantis-control-plane-server/build/docker/Dockerfile
image: "netflixoss/mantiscontrolplaneserver"
workingDirectory: ./mantis-control-plane/mantis-control-plane-server/build/docker
target: mantis-control-plane:mantis-control-plane-server
- dockerfile: ./mantis-server/mantis-server-agent/build/docker/Dockerfile
image: "netflixoss/mantisagent"
target: mantis-server:mantis-server-agent
workingDirectory: ./mantis-server/mantis-server-agent/build/docker
- dockerfile: ./mantis-examples/mantis-examples-mantis-publish-sample/build/docker/Dockerfile
image: "netflixoss/mantis-publisher-sample"
target: mantis-examples:mantis-examples-mantis-publish-sample
workingDirectory: ./mantis-examples/mantis-examples-mantis-publish-sample/build/docker
permissions:
contents: read
packages: write
steps:
- name: Checkout PR
uses: actions/checkout@v3
- name: Setup jdk
uses: actions/setup-java@v1
with:
java-version: 8
- name: Generate dockerfiles
uses: gradle/gradle-build-action@v2
env:
NETFLIX_OSS_SIGNING_KEY: ${{ secrets.ORG_SIGNING_KEY }}
NETFLIX_OSS_SIGNING_PASSWORD: ${{ secrets.ORG_SIGNING_PASSWORD }}
NETFLIX_OSS_REPO_USERNAME: ${{ secrets.ORG_NETFLIXOSS_USERNAME }}
NETFLIX_OSS_REPO_PASSWORD: ${{ secrets.ORG_NETFLIXOSS_PASSWORD }}
with:
arguments: --info --stacktrace ${{ matrix.target }}:dockerCreateDockerfile
- name: Fetch tags
run: |
git fetch --prune --unshallow --tags
- name: Login to Docker Hub
id: login-docker-hub
uses: docker/login-action@v2
with:
username: ${{ secrets.ORG_NETFLIXOSS_DOCKERHUB_USERNAME }}
password: ${{ secrets.ORG_NETFLIXOSS_DOCKERHUB_PASSWORD }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: ${{ matrix.image }}
# generate Docker tags based on the following events/attributes
# we generate the latest tag off the beta branch
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable=${{ github.event_name == 'release' }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build and push Docker images
uses: docker/build-push-action@v3
with:
context: ${{ matrix.workingDirectory }}
file: ${{ matrix.dockerfile }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache