-
Notifications
You must be signed in to change notification settings - Fork 3
Add support for customizing output tag name #24
Description
Currently, the final --tag is based on the repository and server-stage, plus the commit hash. When using GHA's matrix builds to dynamically set --build-args, the resulting outputs either get trampled or need to have a dymaically set repository with the matrix value, which a) isn't necessarily an ideal name and b) can reduce cache re-use across the parallel builds (e.g. with a shared step to download or build dependencies).
I'm thinking the ability to translate this:
name: Build
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
locale:
- en-US
- en-us
- fr-ca
steps:
# ...
- uses: firehed/multistage-docker-build-action@v1
with:
repository: ghcr.io/example/webserver-${{ matrix.locale }}
stages: dependencies
server-stage: server
build-args: locale=${{ matrix.locale }}with something more like this:
# ...
steps:
# ...
- uses: firehed/multistage-docker-build-action@v1
with:
repository: ghcr.io/example/webserver
stages: dependencies
server-stage: server
build-args: locale=${{ matrix.locale }}
# new value
server-name: server-${{ matrix.locale }}Resulting changes:
| Before | After |
|---|---|
| ghcr.io/example/webserver-en-us/dependencies:{internal} | ghcr.io/example/webserver/dependencies:{internal} |
| ghcr.io/example/webserver-en-us/dependencies:{internal} | ghcr.io/example/webserver/dependencies:{internal} |
| ghcr.io/example/webserver-en-ca/dependencies:{internal} | ghcr.io/example/webserver/dependencies:{internal} |
| ghcr.io/example/webserver-fr-ca/dependencies:{internal} | ghcr.io/example/webserver/dependencies:{internal} |
| ghcr.io/example/webserver-en-us/server:abc123 | ghcr.io/example/webserver/server-en-us:abc123 |
| ghcr.io/example/webserver-en-ca/server:abc123 | ghcr.io/example/webserver/server-en-ca:abc123 |
| ghcr.io/example/webserver-fr-ca/server:abc123 | ghcr.io/example/webserver/server-fr-ca:abc123 |
Of note: the dependencies stage collapses, resulting in it being sharable across the matrix. This may not always be the intended behavior; it's important to make it clear when this is appropriate.
This should similarly apply for the testenv-stage.