Cleaning up docker build process #112
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
- .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 | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout PR | |
uses: actions/checkout@v3 | |
- 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: 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 }} |