Git Product home page Git Product logo

create-ecr-repository-action's Introduction

create-ecr-repository-action ts

This is a GitHub Action to create a repository into Amazon ECR or ECR Public registry if it does not exist. It can put a lifecycle policy to the repository for cost saving.

Getting Started

To create a repository:

jobs:
  build:
    steps:
      - uses: int128/create-ecr-repository-action@v1
        with:
          repository: hello-world

If the repository exists, this action does nothing.

Put a lifecycle policy

To create a repository with a lifecycle policy:

      - uses: int128/create-ecr-repository-action@v1
        with:
          repository: hello-world
          lifecycle-policy: config/lifecycle-policy.json

If the repository exists, this action just puts the lifecycle policy.

Create into ECR Public

To create a repository into ECR Public registry:

      - uses: int128/create-ecr-repository-action@v1
        with:
          repository: hello-world
          public: true

If the repository exists, this action does nothing. Note that currently ECR Public does not support the lifecycle polocy.

Full example

Here is a full example to build an image and put it into an ECR repository:

jobs:
  build:
    runs-on: ubuntu-latest
    permissions:
      id-token: write
      contents: read
    steps:
      - uses: aws-actions/configure-aws-credentials@v1
        with:
          role-to-assume: arn:aws:iam::ACCOUNT:role/ROLE
      - uses: aws-actions/amazon-ecr-login@v1
      - uses: int128/create-ecr-repository-action@v1
        id: ecr
        with:
          repository: ${{ github.repository }}
      - uses: docker/metadata-action@v4
        id: metadata
        with:
          images: ${{ steps.ecr.outputs.repository-uri }}
      - uses: docker/build-push-action@v3
        with:
          push: true
          tags: ${{ steps.metadata.outputs.tags }}
          labels: ${{ steps.metadata.outputs.labels }}

Inputs

Name Default Description
public false Set true to create into ECR Public registry
repository (required) Repository name to create
lifecycle-policy - Path to a file of lifecycle policy for the repository
repository-policy - Path to a file of repository policy for the repository

Outputs

Name Description
repository-uri URI of the repository (in form of ACCOUNT.dkr.ecr.REGION.amazonaws.com/NAME or public.ecr.aws/ID/NAME)

create-ecr-repository-action's People

Contributors

alexanderldavis avatar dependabot[bot] avatar github-actions[bot] avatar int128 avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

create-ecr-repository-action's Issues

Support multi region ECR repos

Summary

We replicate our images to multiple regions. It would be good if the action could take a "list" (probably new line separated) of regions to create the repo in.

The default could be to not pass a region to the ECRClient if the parameter is not set.

I will raise a PR to try to implement this if that is ok?

lifecycle-policy file

Is it or would it be possible to point to a file in another repo for the lifecycle-policy.json? Our situation is such that we have a repo with our workflow. This workflow is used by multiple other repos by way of workflow_call. Our lifecycle-policy.json file is in the repo that contains our shared workflow and thus we need to point to that file.

Thoughts or ideas are more than welcomed.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/release.yaml
  • actions/checkout v4.1.6@a5ac7e51b41094c92402da3b24376905380afc29
  • actions/setup-node v4.0.2@60edb5dd545a775178f52524783378180af0d1f8
  • int128/release-typescript-action v1.29.0@ea9cfae1900a4473a9e3efe8f6ba1822140d1229
.github/workflows/ts.yaml
  • actions/checkout v4.1.6@a5ac7e51b41094c92402da3b24376905380afc29
  • actions/setup-node v4.0.2@60edb5dd545a775178f52524783378180af0d1f8
  • actions/checkout v4.1.6@a5ac7e51b41094c92402da3b24376905380afc29
  • actions/setup-node v4.0.2@60edb5dd545a775178f52524783378180af0d1f8
  • int128/update-generated-files-action v2.51.0@96ac74aa35f9d2e748335b60e7f3260304d22a6b
npm
package.json
  • @actions/core 1.10.1
  • @aws-sdk/client-ecr 3.588.0
  • @aws-sdk/client-ecr-public 3.588.0
  • @tsconfig/node20 20.1.4
  • @types/jest 29.5.12
  • @types/node 20.14.0
  • @vercel/ncc 0.38.1
  • aws-sdk-client-mock 4.0.1
  • eslint 9.4.0
  • eslint-plugin-jest 28.5.0
  • jest 29.7.0
  • prettier 3.3.0
  • ts-jest 29.1.4
  • typescript 5.4.5
  • typescript-eslint 7.12.0
  • pnpm 9.1.4
regex
action.yaml
  • node 20
.github/workflows/release.yaml
  • node 20
.github/workflows/ts.yaml
  • node 20
  • node 20

  • Check this box to trigger a request for Renovate to run again on this repository

repositoryName regex bug?

repository: account.ecr.us-east-1.amazonaws.com/org/repo

Error: InvalidParameterException: Invalid parameter at 'repositoryName' failed to satisfy constraint: 'must satisfy regular expression '(?:[a-z0-9]+(?:[.-][a-z0-9]+)/)[a-z0-9]+(?:[.-][a-z0-9]+)*''

ECR's spec is:
20 out of 256 characters maximum (2 minimum). The name must start with a letter and can only contain lowercase letters, numbers, hyphens, underscores, and forward slashes.

And I'd really like to use that forward slash since we have multiple orgs in our enterprise.

I'll see if I can find time to submit a PR... but it's not promising. :)

Thanks,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.