build.yml
Triggered when a PR is merged into develop. Builds and publishes the artifact for the development iteration.
What It Does
Steps
- Set Variables (deployable only) — reads the project version from
pom.xml, strips-SNAPSHOT, and constructs the image tag as<version>.<github.run_number>and the image registry URL. - Configure AWS Credentials — authenticates with AWS using
aws-actions/configure-aws-credentials@v4. - Auth via AWS ECR (deployable only) — logs Docker into the ECR registry.
- Configure Maven for CodeArtifact — obtains a short-lived CodeArtifact token and writes
~/.m2/settings.xmlwith the release and snapshot server credentials. - Deploy Library Artifact (library only) — runs
mvn deploy -Pbuildto publish the SNAPSHOT JAR to CodeArtifact. - Build image (deployable only) — runs
mvn spring-boot:build-imageto produce a Docker image. - Push image to ECR (deployable only) — pushes three tags:
x.x.x.<run_number>,latest, and the 8-character commit hash.
The SERVICE_NAME Discriminator
SERVICE_NAME is an optional workflow input with an empty default. Its presence or absence determines which steps execute:
SERVICE_NAME | Path taken |
|---|---|
| Omitted | Maven library → mvn deploy → CodeArtifact SNAPSHOT |
my-service | Spring Boot Docker image → ECR tagged x.x.x.<run_num> / latest / sha |
Image Tag Format
For deployable builds, the image tag includes the build number to make every build uniquely addressable even before a release:
<version>.<github.run_number> e.g. 1.3.0.42
latest
<8-char commit hash> e.g. a1b2c3d4
This differs from the release tag format — see release.yml for comparison.
Maven Profile
All Maven commands pass -Pbuild. Your project's pom.xml must define a build profile. The exec-maven-plugin submodule-update executions are typically bound to the default lifecycle; the build profile suppresses them on CI. See Getting Started for the Maven configuration.