Builds docker-compose based project images and pushes them to registry.
All services with build key are built and tagged with provided tags. Tags and image names should be generated by using environment variables provided by this action. For example:
PROJECT_IMAGE
- image namePROJECT_VERSION
- image version
services:
frontend:
image: ${PROJECT_IMAGE:-my-project-name}:${PROJECT_VERSION:-latest}
build:
context: .
args:
- MY_APP_VERSION=${PROJECT_VERSION:-latest}
These variables are also returned in output of this action as project-image
and project-version
respectively. Use these if you need to spin up built
images in the workflow.
You can specify following options in with
section of this action:
registry
- registry to push images to. Default isghcr.io
.build
- build images. Default istrue
.push
- push images to registry. Default istrue
.docker_compose_file
- path to docker-compose file. Default isdocker-compose.yml
.
An example usage of this action in build workflow.
name: Build Image
on:
workflow_call:
workflow_dispatch:
push:
branches: [main]
env:
REGISTRY: ghcr.io
jobs:
build_image:
name: Build Image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build & push
uses: imatic/imatic-build-action
with:
registry: ${{ env.REGISTRY }}