Skip to main content

build.yml

Triggered when a PR is merged into develop. Builds and publishes the artifact for the development iteration.

What It Does

Steps

  1. 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.
  2. Configure AWS Credentials — authenticates with AWS using aws-actions/configure-aws-credentials@v4.
  3. Auth via AWS ECR (deployable only) — logs Docker into the ECR registry.
  4. Configure Maven for CodeArtifact — obtains a short-lived CodeArtifact token and writes ~/.m2/settings.xml with the release and snapshot server credentials.
  5. Deploy Library Artifact (library only) — runs mvn deploy -Pbuild to publish the SNAPSHOT JAR to CodeArtifact.
  6. Build image (deployable only) — runs mvn spring-boot:build-image to produce a Docker image.
  7. 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_NAMEPath taken
OmittedMaven library → mvn deploy → CodeArtifact SNAPSHOT
my-serviceSpring 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.