diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..21f1c06 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,13 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + 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 new file mode 100644 index 0000000..51e2bdd --- /dev/null +++ b/.github/workflows/push-to-ecr.yml @@ -0,0 +1,59 @@ +name: Build and Push to ECR + +on: + push: + branches: [main] + pull_request: + branches: [main] + workflow_dispatch: + +# Required for requesting the OIDC JWT token +permissions: + id-token: write + contents: read + +env: + ECR_REPOSITORY: aws-lambda-nodejs-runtime + +jobs: + build-and-push: + strategy: + fail-fast: false + matrix: + include: + - arch: amd64 + runner-label: codebuild-project-aws-aws-lambda-nodejs-runtime-x86-${{ github.run_id }}-${{ github.run_attempt }} + - 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: 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" + docker tag "$ECR_REPOSITORY:$ARCH" "$IMAGE" + docker push "$IMAGE" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3dcf97e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,4 @@ +FROM scratch +ARG ARCH=unknown +LABEL dev.maxday.image.architecture=$ARCH +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