From 893d31b3362f5605699bc878b893842f3b0c7e0a Mon Sep 17 00:00:00 2001 From: Maxime David Date: Mon, 12 Oct 2026 13:51:31 +0000 Subject: [PATCH 1/9] feat: init --- .github/workflows/push-to-ecr.yml | 39 +++++++++++++++++++++++++++++++ Dockerfile | 2 ++ hello.txt | 1 + 3 files changed, 42 insertions(+) create mode 100644 .github/workflows/push-to-ecr.yml create mode 100644 Dockerfile create mode 100644 hello.txt diff --git a/.github/workflows/push-to-ecr.yml b/.github/workflows/push-to-ecr.yml new file mode 100644 index 0000000..24d5abd --- /dev/null +++ b/.github/workflows/push-to-ecr.yml @@ -0,0 +1,39 @@ +name: Build and Push to ECR + +on: + push: + branches: [main] + workflow_dispatch: + +# Required for requesting the OIDC JWT token +permissions: + id-token: write + contents: read + +env: + ECR_REPOSITORY: aws-lambda-nodejs-runtime + IMAGE_TAG: ${{ github.sha }} + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Configure AWS credentials (OIDC) + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_IAM_ROLE }} + aws-region: ${{ secrets.AWS_REGION }} + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 + + - name: Build and push image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + run: | + docker build -t "$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" . + docker push "$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0ce6948 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,2 @@ +FROM scratch +COPY hello.txt /hello.txt diff --git a/hello.txt b/hello.txt new file mode 100644 index 0000000..cdf5bbe --- /dev/null +++ b/hello.txt @@ -0,0 +1 @@ +hello from maxday From 79ee56fca58dffe5f9782e5ab25c0ddb211ed8ef Mon Sep 17 00:00:00 2001 From: Maxime David Date: Mon, 12 Oct 2026 13:56:10 +0000 Subject: [PATCH 2/9] feat: init --- .github/workflows/push-to-ecr.yml | 23 ++++++++++++++++++----- Dockerfile | 2 ++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/.github/workflows/push-to-ecr.yml b/.github/workflows/push-to-ecr.yml index 24d5abd..fee4824 100644 --- a/.github/workflows/push-to-ecr.yml +++ b/.github/workflows/push-to-ecr.yml @@ -12,11 +12,19 @@ permissions: env: ECR_REPOSITORY: aws-lambda-nodejs-runtime - IMAGE_TAG: ${{ github.sha }} + CODEBUILD_PROJECT: aws-lambda-nodejs-runtime jobs: build-and-push: - runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - arch: amd64 + runner-label: codebuild-aws-lambda-nodejs-runtime-${{ github.run_id }}-${{ github.run_attempt }}-ubuntu-7.0-small + - arch: arm64 + runner-label: codebuild-aws-lambda-nodejs-runtime-${{ github.run_id }}-${{ github.run_attempt }}-arm-3.0-small + runs-on: ${{ matrix.runner-label }} steps: - name: Checkout uses: actions/checkout@v4 @@ -31,9 +39,14 @@ jobs: id: login-ecr uses: aws-actions/amazon-ecr-login@v2 - - name: Build and push image + - name: Build image env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ARCH: ${{ matrix.arch }} run: | - docker build -t "$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" . - docker push "$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" + IMAGE="$ECR_REGISTRY/$ECR_REPOSITORY:${{ github.sha }}-$ARCH" + echo "IMAGE=$IMAGE" >> "$GITHUB_ENV" + docker build --build-arg "ARCH=$ARCH" -t "$IMAGE" . + + - name: Push image + run: docker push "$IMAGE" diff --git a/Dockerfile b/Dockerfile index 0ce6948..3797009 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,2 +1,4 @@ FROM scratch +ARG ARCH=unknown +LABEL org.opencontainers.image.architecture=$ARCH COPY hello.txt /hello.txt From 5e38be4ac7e23ee7f427291c866d43e6f58d6e7b Mon Sep 17 00:00:00 2001 From: Maxime David Date: Mon, 12 Oct 2026 13:57:41 +0000 Subject: [PATCH 3/9] fix: init --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3797009..3dcf97e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ FROM scratch ARG ARCH=unknown -LABEL org.opencontainers.image.architecture=$ARCH +LABEL dev.maxday.image.architecture=$ARCH COPY hello.txt /hello.txt From a2225847b17f7e3cc1ee7a5853c63bf9648643cd Mon Sep 17 00:00:00 2001 From: Maxime David Date: Mon, 12 Oct 2026 16:21:45 +0000 Subject: [PATCH 4/9] fix: runner names --- .github/workflows/push-to-ecr.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/push-to-ecr.yml b/.github/workflows/push-to-ecr.yml index fee4824..39aa07e 100644 --- a/.github/workflows/push-to-ecr.yml +++ b/.github/workflows/push-to-ecr.yml @@ -12,7 +12,6 @@ permissions: env: ECR_REPOSITORY: aws-lambda-nodejs-runtime - CODEBUILD_PROJECT: aws-lambda-nodejs-runtime jobs: build-and-push: @@ -21,9 +20,9 @@ jobs: matrix: include: - arch: amd64 - runner-label: codebuild-aws-lambda-nodejs-runtime-${{ github.run_id }}-${{ github.run_attempt }}-ubuntu-7.0-small + runner-label: codebuild-project-aws-aws-lambda-nodejs-runtime-x86-${{ github.run_id }}-${{ github.run_attempt }} - arch: arm64 - runner-label: codebuild-aws-lambda-nodejs-runtime-${{ github.run_id }}-${{ github.run_attempt }}-arm-3.0-small + runner-label: codebuild-project-aws-aws-lambda-nodejs-runtime-arm64-${{ github.run_id }}-${{ github.run_attempt }} runs-on: ${{ matrix.runner-label }} steps: - name: Checkout From 08a56a355dedcd2c010880567ef187d8ce0f3a82 Mon Sep 17 00:00:00 2001 From: Maxime David Date: Mon, 12 Oct 2026 16:26:42 +0000 Subject: [PATCH 5/9] ci: pin actions to SHAs, target per-arch CodeBuild runners, add Dependabot - Pin checkout (v7.0.1), configure-aws-credentials (v6.3.0) and amazon-ecr-login (v2.1.7) to commit SHAs with version comments. - Point the amd64/arm64 matrix runs-on labels at the two per-arch CodeBuild projects (project-aws-aws-lambda-nodejs-runtime-x86/-arm64). - Add .github/dependabot.yml to keep the action pins updated weekly. --- .github/dependabot.yml | 17 +++++++++++++++++ .github/workflows/push-to-ecr.yml | 6 +++--- 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..d3ccd7f --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,17 @@ +version: 2 +updates: + # Keep the SHA-pinned GitHub Actions in .github/workflows up to date. + # Dependabot bumps both the pinned commit SHA and the trailing `# vX.Y.Z` + # version comment, so the pins stay current without losing SHA pinning. + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + # One grouped PR for all action bumps instead of one per action. + groups: + github-actions: + patterns: + - "*" + commit-message: + prefix: "ci" + open-pull-requests-limit: 5 diff --git a/.github/workflows/push-to-ecr.yml b/.github/workflows/push-to-ecr.yml index 39aa07e..b1bf059 100644 --- a/.github/workflows/push-to-ecr.yml +++ b/.github/workflows/push-to-ecr.yml @@ -26,17 +26,17 @@ jobs: runs-on: ${{ matrix.runner-label }} steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Configure AWS credentials (OIDC) - uses: aws-actions/configure-aws-credentials@v4 + uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0 with: role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_IAM_ROLE }} aws-region: ${{ secrets.AWS_REGION }} - name: Login to Amazon ECR id: login-ecr - uses: aws-actions/amazon-ecr-login@v2 + uses: aws-actions/amazon-ecr-login@03f1aad4c6c7ffd436567f42f9384779290529bd # v2.1.7 - name: Build image env: From 268b9601fe582bf5798022a761ad843153fea216 Mon Sep 17 00:00:00 2001 From: Maxime David Date: Mon, 12 Oct 2026 16:27:18 +0000 Subject: [PATCH 6/9] feat: init --- .github/dependabot.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index d3ccd7f..21f1c06 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,13 +1,9 @@ version: 2 updates: - # Keep the SHA-pinned GitHub Actions in .github/workflows up to date. - # Dependabot bumps both the pinned commit SHA and the trailing `# vX.Y.Z` - # version comment, so the pins stay current without losing SHA pinning. - package-ecosystem: "github-actions" directory: "/" schedule: interval: "weekly" - # One grouped PR for all action bumps instead of one per action. groups: github-actions: patterns: From 38098880ec1f4b57a1e99bb727ea0d0faf676206 Mon Sep 17 00:00:00 2001 From: Maxime David Date: Mon, 12 Oct 2026 16:34:20 +0000 Subject: [PATCH 7/9] ci: run workflow on PRs to main, gate image push to push events only Adds a pull_request trigger so PRs build both arches, and guards the push step with 'if: github.event_name == push' so images are only pushed on merge to main. --- .github/workflows/push-to-ecr.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/push-to-ecr.yml b/.github/workflows/push-to-ecr.yml index b1bf059..e09f8ac 100644 --- a/.github/workflows/push-to-ecr.yml +++ b/.github/workflows/push-to-ecr.yml @@ -3,6 +3,8 @@ name: Build and Push to ECR on: push: branches: [main] + pull_request: + branches: [main] workflow_dispatch: # Required for requesting the OIDC JWT token @@ -48,4 +50,5 @@ jobs: docker build --build-arg "ARCH=$ARCH" -t "$IMAGE" . - name: Push image + if: github.event_name == 'push' run: docker push "$IMAGE" From 4b12968c6ec251c9f630b637f66a922e9b8a8665 Mon Sep 17 00:00:00 2001 From: Maxime David Date: Mon, 12 Oct 2026 19:18:57 +0000 Subject: [PATCH 8/9] ci: assume role via single AWS_ROLE_ARN secret Use the full role ARN from one secret instead of constructing it from AWS_ACCOUNT_ID + AWS_IAM_ROLE, removing the doubled-ARN failure mode. --- .github/workflows/push-to-ecr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push-to-ecr.yml b/.github/workflows/push-to-ecr.yml index e09f8ac..e1d0c2d 100644 --- a/.github/workflows/push-to-ecr.yml +++ b/.github/workflows/push-to-ecr.yml @@ -33,7 +33,7 @@ jobs: - name: Configure AWS credentials (OIDC) uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0 with: - role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_IAM_ROLE }} + role-to-assume: ${{ secrets.AWS_ROLE_ARN }} aws-region: ${{ secrets.AWS_REGION }} - name: Login to Amazon ECR From 9303b1b615a9d10bceca44bbf20b8a328a694352 Mon Sep 17 00:00:00 2001 From: Maxime David Date: Wed, 14 Oct 2026 12:39:11 +0000 Subject: [PATCH 9/9] feat: use env --- .github/workflows/push-to-ecr.yml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/push-to-ecr.yml b/.github/workflows/push-to-ecr.yml index e1d0c2d..51e2bdd 100644 --- a/.github/workflows/push-to-ecr.yml +++ b/.github/workflows/push-to-ecr.yml @@ -26,29 +26,34 @@ jobs: - arch: arm64 runner-label: codebuild-project-aws-aws-lambda-nodejs-runtime-arm64-${{ github.run_id }}-${{ github.run_attempt }} runs-on: ${{ matrix.runner-label }} + environment: ${{ github.event_name == 'push' && 'deploy' || '' }} steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - name: Build image + env: + ARCH: ${{ matrix.arch }} + run: docker build --build-arg "ARCH=$ARCH" -t "$ECR_REPOSITORY:$ARCH" . + - name: Configure AWS credentials (OIDC) + if: github.event_name == 'push' uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0 with: role-to-assume: ${{ secrets.AWS_ROLE_ARN }} aws-region: ${{ secrets.AWS_REGION }} - name: Login to Amazon ECR + if: github.event_name == 'push' id: login-ecr uses: aws-actions/amazon-ecr-login@03f1aad4c6c7ffd436567f42f9384779290529bd # v2.1.7 - - name: Build image + - name: Push image + if: github.event_name == 'push' env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} ARCH: ${{ matrix.arch }} run: | IMAGE="$ECR_REGISTRY/$ECR_REPOSITORY:${{ github.sha }}-$ARCH" - echo "IMAGE=$IMAGE" >> "$GITHUB_ENV" - docker build --build-arg "ARCH=$ARCH" -t "$IMAGE" . - - - name: Push image - if: github.event_name == 'push' - run: docker push "$IMAGE" + docker tag "$ECR_REPOSITORY:$ARCH" "$IMAGE" + docker push "$IMAGE"