Skip to content

Dockerfile Builder #5088

Dockerfile Builder

Dockerfile Builder #5088

name: Dockerfile Builder
on:
# We need to run this workflow after NPM publisher otherwise Docker is going to try to create
# images with NPM packages (versions) that do not exist in the registry yet.
# See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_run
workflow_run:
workflows: ['NPM Publisher']
branches:
- master
types:
- completed
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
jobs:
# https://docs.docker.com/ci-cd/github-actions/
build-and-publish:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
strategy:
fail-fast: false
matrix:
project:
- 'abacus'
- 'abacus-backoffice'
- 'abacus-kochka'
- 'abacus-tools'
- 'mrtnzlml-meta'
include:
- project: abacus
projectPath: './src/abacus'
projectDockerfile: './src/abacus/Dockerfile'
projectImageName: 'adeira/abacus'
- project: abacus-backoffice
projectPath: './src/abacus-backoffice'
projectDockerfile: './src/abacus-backoffice/Dockerfile'
projectImageName: 'adeira/abacus-backoffice'
- project: abacus-kochka
projectPath: './src/abacus-kochka'
projectDockerfile: './src/abacus-kochka/Dockerfile'
projectImageName: 'adeira/abacus-kochka'
- project: abacus-tools
projectPath: './src/abacus-tools'
projectDockerfile: './src/abacus-tools/Dockerfile'
projectImageName: 'adeira/abacus-tools'
- project: mrtnzlml-meta
projectPath: './src/mrtnzlml-meta'
projectDockerfile: './src/mrtnzlml-meta/Dockerfile'
projectImageName: 'adeira/mrtnzlml-meta'
steps:
# https://github.com/actions/checkout
- uses: actions/[email protected]
with:
# Number of commits to fetch. 0 indicates all history for all branches and tags.
fetch-depth: 0
# https://github.com/docker/login-action
- name: Login to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
id: buildx
uses: docker/[email protected]
# https://github.com/docker/metadata-action
- name: Collect Docker metadata
id: meta
uses: docker/[email protected]
with:
images: ${{ matrix.projectImageName }}
flavor: |
latest=true
tags: |
type=sha
# https://github.com/docker/build-push-action
- name: Build and push
id: docker_build
uses: docker/[email protected]
with:
context: ${{ matrix.projectPath }}
file: ${{ matrix.projectDockerfile }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
secrets: |
SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}