Skip to content

feat: add build_args to docker-push and a node-version workflow - #209

Merged
cdelfabbro merged 7 commits into
masterfrom
feat/docker-push-node-version
Oct 1, 2026
Merged

cdelfabbro merged 7 commits into
masterfrom
feat/docker-push-node-version

Conversation

@cdelfabbro

@cdelfabbro cdelfabbro commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

IA;DR

Deux ajouts pour qu'une image Node.js ne contienne plus de version de Node en dur, sans que docker-push-v4 ait la moindre notion de Node :

  • docker-push-v4 (et docker-experiment-v2) acceptent des build args génériques (build_args), utiles à n'importe quel repo ;
  • un nouveau workflow réutilisable, node-version-v1, lit la version majeure de engines.node dans package.json.

Les deux sont facultatifs : les repos existants ne voient aucun changement. Premier utilisateur : sencrop/sencrop-bali-api#5821 (migration npm → pnpm).

What

docker-push-v4 / docker-experiment-v2

  • Nouvelle entrée build_args (vide par défaut), un KEY=value par ligne, transmise à docker/build-push-action. docker-experiment-v2 la transmet à docker-push-v4.

node-version-v1

  • Output major : la première version numérique de engines.node (24 pour ^24.15.0 ou 24.x). C'est la règle qu'applique déjà devenv : poste de dev, CI et image suivent la même majeure.
  • Entrée working_directory pour un package.json ailleurs qu'à la racine.
  • Échoue avec une annotation si engines.node est absent ou ne contient aucune version.
  • Checkout partiel : seul package.json est récupéré.

Utilisation

jobs:
  node-version:
    uses: sencrop/github-workflows/.github/workflows/node-version-v1.yml@master

  image:
    needs: [node-version]
    uses: sencrop/github-workflows/.github/workflows/docker-push-v4.yml@master
    secrets: inherit
    with:
      image_name: your-image-name
      image_tag: your-image-tag
      cpu_architecture: arm64
      build_args: NODE_VERSION=${{ needs.node-version.outputs.major }}
ARG NODE_VERSION
FROM node:${NODE_VERSION}-bookworm

Le tag de la majeure (node:24-bookworm) désigne toujours la dernière 24.x publiée sur Docker Hub. Une version exacte résolue depuis nodejs.org (avec actions/setup-node) pourrait précéder de quelques heures la publication de son image, et faire échouer le build entre-temps.

README : sections docker-push (build args) et Node version.

Validation

Chaîne complète testée et validée sur sencrop/sencrop-bali-api#5821 par le build expérimental (run 36846137635, détails) : node-version-v1 → major=24 → build_args → FROM node:24-bookworm → push ECR.

Reste à faire

  • Annuler le commit chore: pin docker-push-v4 on this branch… avant le merge : docker-experiment-v2 y appelle docker-push-v4 sur cette branche, pour tester la chaîne complète depuis le build expérimental de sencrop/sencrop-bali-api#5821.

@cdelfabbro cdelfabbro changed the title feat(docker-push): resolve the Node.js version from a project file feat(docker-push): pass the Node.js version of the project to the build Oct 1, 2026
@cdelfabbro cdelfabbro changed the title feat(docker-push): pass the Node.js version of the project to the build feat: add build_args to docker-push and a node-version workflow Oct 1, 2026
@cdelfabbro
cdelfabbro requested a balanced review from Copilot October 1, 2026 09:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The missing-version path exits before emitting its intended error annotation.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds reusable Node.js version extraction and generic Docker build arguments.

Changes:

  • Adds node-version-v1.
  • Passes build arguments through Docker workflows.
  • Documents both features.
File Description
README.md Documents usage.
.github/​workflows/​node-version-v1.yml Extracts the Node.js major version.
.github/​workflows/​docker-push-v4.yml Forwards Docker build arguments.
.github/​workflows/​docker-experiment-v2.yml Passes build arguments downstream.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .github/workflows/node-version-v1.yml Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

The default Node-version invocation can omit the root package.json due to its sparse-checkout pattern.

Review effort: Balanced
Findings: None

Resolved since last review (1)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Root sparse-checkout pattern incorrectly uses ./package.json

.github/​workflows/​node-version-v1.yml:28

The default working_directory produces the non-cone sparse-checkout pattern ./package.json. Non-cone mode interprets this as a gitignore-style pattern, where the leading ./ does not match the repository-relative path package.json; the default invocation can therefore omit the file and fail in the read step. Emit package.json explicitly for the root case.

@cdelfabbro

Copy link
Copy Markdown
Contributor Author

Copilot (review du 01/10) : le motif ./package.json du checkout partiel par défaut. Corrigé dans 1b972ab.

  • C'est confirmé avec git 2.55 en mode non-cone : ./package.json ne récupère aucun fichier, donc l'appel par défaut aurait échoué. Sans / initial, package.json récupère au contraire tous les package.json du repo, à n'importe quelle profondeur.
  • Le motif est désormais ancré à la racine : /package.json, ou /<working_directory>/package.json. Vérifié en local : seul le fichier attendu est récupéré.
  • Le step de lecture n'utilise plus working-directory:, qui échouait avant le script quand le dossier manquait. Il vérifie lui-même que le fichier existe, et affiche une erreur explicite qui rappelle le format attendu (chemin relatif, sans ./).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The optional inputs are propagated consistently, and the new workflow handles documented success and failure paths correctly.

Review effort: Balanced
Findings: None

@cdelfabbro

Copy link
Copy Markdown
Contributor Author

✅ Testé et validé sur sencrop/sencrop-bali-api#5821, avec le build expérimental (run 36846137635). Pour ce test, experiment.yml (bali) et docker-experiment-v2 (cette branche) étaient pinnés sur feat/docker-push-node-version.

Étape Résultat
node-version-v1 checkout partiel /package.json, major=24 lu dans ^24.15.0 (7 s)
docker-experiment-v2 → docker-push-v4 build_args: NODE_VERSION=24 transmis, docker buildx build --build-arg NODE_VERSION=24
Image FROM node:24-bookworm (les deux stages), pnpm 12.8.1, nest build avec type check OK
Push ECR tag x36846137635, commentaire de PR et tag git créés

Avant le merge : annuler le commit chore: pin docker-push-v4 on this branch….

@cdelfabbro
cdelfabbro merged commit 4db5c74 into master Oct 1, 2026
1 check passed
@cdelfabbro
cdelfabbro deleted the feat/docker-push-node-version branch October 1, 2026 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants