Dockerfile Builder #3861
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: 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-docs' | |
- 'abacus-kochka' | |
- 'abacus-tools' | |
- 'mrtnzlml-meta' | |
include: | |
- project: abacus | |
projectPath: './src/abacus' | |
projectGlob: './src/abacus/**' | |
projectDockerfile: './src/abacus/Dockerfile' | |
projectImageName: 'adeira/abacus' | |
- project: abacus-backoffice | |
projectPath: './src/abacus-backoffice' | |
projectGlob: './src/abacus-backoffice/**' | |
projectDockerfile: './src/abacus-backoffice/Dockerfile' | |
projectImageName: 'adeira/abacus-backoffice' | |
- project: abacus-docs | |
projectPath: './src/abacus-docs' | |
projectGlob: './src/abacus-docs/**' | |
projectDockerfile: './src/abacus-docs/Dockerfile' | |
projectImageName: 'adeira/abacus-docs' | |
- project: abacus-kochka | |
projectPath: './src/abacus-kochka' | |
projectGlob: './src/abacus-kochka/**' | |
projectDockerfile: './src/abacus-kochka/Dockerfile' | |
projectImageName: 'adeira/abacus-kochka' | |
- project: abacus-tools | |
projectPath: './src/abacus-tools' | |
projectGlob: './src/abacus-tools/**' | |
projectDockerfile: './src/abacus-tools/Dockerfile' | |
projectImageName: 'adeira/abacus-tools' | |
- project: mrtnzlml-meta | |
projectPath: './src/mrtnzlml-meta' | |
projectGlob: './src/mrtnzlml-meta/**' | |
projectDockerfile: './src/mrtnzlml-meta/Dockerfile' | |
projectImageName: 'adeira/mrtnzlml-meta' | |
steps: | |
# https://github.com/actions/checkout | |
- uses: actions/checkout@v4.1.0 | |
with: | |
# Number of commits to fetch. 0 indicates all history for all branches and tags. | |
fetch-depth: 0 | |
# https://github.com/dorny/paths-filter | |
- uses: dorny/paths-filter@v2.11.1 | |
id: changes | |
with: | |
filters: | | |
src: | |
- ${{ matrix.projectGlob }} | |
# https://github.com/docker/login-action | |
- name: Login to Docker Hub | |
if: steps.changes.outputs.src == 'true' | |
uses: docker/login-action@v3.0.0 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
# https://github.com/docker/setup-buildx-action | |
- name: Set up Docker Buildx | |
if: steps.changes.outputs.src == 'true' | |
id: buildx | |
uses: docker/setup-buildx-action@v3.0.0 | |
# https://github.com/docker/metadata-action | |
- name: Collect Docker metadata | |
if: steps.changes.outputs.src == 'true' | |
id: meta | |
uses: docker/metadata-action@v5.0.0 | |
with: | |
images: ${{ matrix.projectImageName }} | |
flavor: | | |
latest=true | |
tags: | | |
type=sha | |
# https://github.com/docker/build-push-action | |
- name: Build and push | |
if: steps.changes.outputs.src == 'true' | |
id: docker_build | |
uses: docker/build-push-action@v5.0.0 | |
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 | |
if: steps.changes.outputs.src == 'true' | |
run: echo ${{ steps.docker_build.outputs.digest }} |