Git Product home page Git Product logo

ensure-ecr-repo's Introduction

CI Test

BYU logo github-action-create-ecr-repo-if-missing

A GitHub Action for creating AWS ECR repositories

Usage

on: push
# ...
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      # ...
      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v1
        with:
          aws-access-key-id: ${{ secrets.AWS_KEY }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET }}
          aws-region: us-west-2
      - name: Log into Amazon ECR
        uses: aws-actions/amazon-ecr-login@v1
      - name: Create ECR repo if missing
        uses: byu-oit/github-action-create-ecr-repo-if-missing@v2
        with:
          DOCKER_REPO_NAME: ${{ env.REPO }} # Your repo name goes here
      # ...
Or for a more complicated example, if you want to retain a certain number of tagged images...

on: push
# ...
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      # ...
      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v1
        with:
          aws-access-key-id: ${{ secrets.AWS_KEY }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET }}
          aws-region: us-west-2
      - name: Log into Amazon ECR
        uses: aws-actions/amazon-ecr-login@v1
      - name: Create ECR repo if missing
        uses: byu-oit/github-action-create-ecr-repo-if-missing@v2
        with:
          DOCKER_REPO_NAME: ${{ env.REPO }} # Your repo name goes here
          NUM_DAYS_BEFORE_EXPIRING_UNTAGGED_IMAGES: 14
          TAG_PREFIX: 'dev-v'
          NUM_TAGGED_IMAGES_TO_RETAIN: 5
      # ...

AWS IAM Requirements

In order for this action to perform correctly, the IAM user must have the following policy actions granted:

        - PolicyName: 'ECR'
          PolicyDocument:
            Version: '2012-10-17'
            Statement:
              - Effect: 'Allow'
                Action:
                  - 'ecr:GetAuthorizationToken'
                Resource:
                  - '*'
              - Effect: 'Allow'
                Action:
                  - 'ecr:CreateRepository'
                  - 'ecr:DescribeRepositories'
                  - 'ecr:PutLifecyclePolicy'
                  - 'ecr:SetRepositoryPolicy'
                  - 'ecr:InitiateLayerUpload'
                  - 'ecr:UploadLayerPart'
                  - 'ecr:CompleteLayerUpload'
                  - 'ecr:PutImage'
                  - 'ecr:BatchGetImage'
                  - 'ecr:BatchCheckLayerAvailability'
                  - 'ecr:ListImages'
                Resource:
                  - !Sub 'arn:aws:ecr:*:${AWS::AccountId}:repository/*'

Contributing

Hopefully this is useful to others at BYU. Feel free to ask me some questions about it, but I make no promises about being able to commit time to support it.

Modifying Source Code

Just run npm install locally. There aren't many files here, so hopefully it should be pretty straightforward.

Cutting new releases

GitHub Actions will run the entry point from the action.yml. In our case, that happens to be /dist/index.js.

Actions run from GitHub repos. We don't want to check in node_modules. Hence, we package the app using npm run package.

Then, be sure to create a new GitHub release, following SemVer.

ensure-ecr-repo's People

Contributors

chrisjohnson00 avatar dependabot[bot] avatar garygsc avatar haylowry avatar jlast35 avatar joshgubler avatar jvisker avatar sankar4n avatar tombates6 avatar yoshutch avatar

Forkers

todaypay

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.