Skip to content

feat: add app_name input to build.yml for single-app image name override #104

@bedatty

Description

@bedatty

Summary

Add an app_name input to the build.yml reusable workflow to allow callers to override the Docker image name in single-app mode. This enables repositories with multiple Docker images (different Dockerfiles) to call the shared workflow multiple times with different image names.

Problem

Currently, in single-app mode (no filter_paths), the image name is hardcoded to github.event.repository.name:

# build.yml - set-matrix step
APP_NAME="${{ github.event.repository.name }}"
echo "matrix=[{\"name\": \"${APP_NAME}\", \"working_dir\": \".\"}]" >> $GITHUB_OUTPUT

Repositories like plugin-br-pix-direct-jd need to build two separate Docker images from different Dockerfiles (docker-app.Dockerfile and docker-job.Dockerfile) with different image names (plugin-br-pix-direct-jd and plugin-br-pix-direct-jd-job).

Without an override, both calls produce the same image name, making it impossible to use the shared workflow for this pattern.

Proposed Solution

Add an app_name input:

app_name:
  description: 'Override app/image name (single-app mode only). Defaults to repository name.'
  type: string
  default: ''

Update the set-matrix step to use it:

- name: Set matrix
  id: set-matrix
  run: |
    if [ -z "${{ inputs.filter_paths }}" ]; then
      APP_NAME="${{ inputs.app_name || github.event.repository.name }}"
      echo "matrix=[{\"name\": \"${APP_NAME}\", \"working_dir\": \".\"}]" >> $GITHUB_OUTPUT
      echo "has_builds=true" >> $GITHUB_OUTPUT
    else
      # monorepo mode unchanged
    fi

Usage Example

jobs:
  build_pix:
    uses: LerianStudio/github-actions-shared-workflows/.github/workflows/build.yml@main
    with:
      app_name: 'plugin-br-pix-direct-jd'
      dockerfile_name: 'docker-app.Dockerfile'
      enable_ghcr: true
    secrets: inherit

  build_job:
    uses: LerianStudio/github-actions-shared-workflows/.github/workflows/build.yml@main
    with:
      app_name: 'plugin-br-pix-direct-jd-job'
      dockerfile_name: 'docker-job.Dockerfile'
      enable_ghcr: true
    secrets: inherit

Impact

  • Non-breaking change (default behavior unchanged)
  • Enables TypeScript/Node.js plugins with multiple Docker images to adopt the shared workflow
  • Reduces workflow duplication across repositories

Metadata

Metadata

Assignees

Labels

enhancementNew feature or improvement request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions