GuardianAngel
GuardianAngel

Reputation: 1

How to deploy helm chart to ecr via github actions?

Im trying to create a github action which will push to ECR , how do I push helm chart to ECR with Actions yaml?

Upvotes: 0

Views: 2827

Answers (2)

Salizar Marxx
Salizar Marxx

Reputation: 933

  1. Configure AWS Credentials
  2. Configuration AWS ECR Login ** Please note that at the time of this writing this action does not support helm repository logins. You need to use a different branch, aws-actions/amazon-ecr-login**@arjraman**
  3. use helm to package the chart using helm package
  4. use helm to push the packaged chart to the ECR using helm push

Here's a custom action that utilizes the steps described above.

name: AWS Helm
description: AWS Setup and Helm Chart
inputs:
  aws-access-key-id:
    description: The AWS access Key id
    required: true
  aws-secret-access-key:
    description: The AWS access key
    required: true
  ecr-repository-name:
    description: the name of the ecr repository
    required: true
  aws-region:
      description: The AWS region, default us-east-2
      default: us-east-2
      required: false
  tag-name:
    description: image tag name
    required: true
  chart-path:
    description: the directory path to the specified chart
    required: true
runs:
  using: "composite"
  steps:
    - uses: aws-actions/configure-aws-credentials@v1
      with:
        aws-access-key-id: ${{ inputs.aws-access-key-id }}
        aws-secret-access-key: ${{ inputs.aws-secret-access-key }}
        aws-region: ${{ inputs.aws-region }}
    # This is  an un-official build that allows helm login to the ECR
    - uses: aws-actions/amazon-ecr-login@arjraman
      id: login-ecr
    - name: Helm Chart
      env:
          ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
          ECR_REPOSITORY: ${{ inputs.ecr-repository-name }}
      run : |
        helm package \
        ${{ inputs.chart-path }} \
        --app-version ${{ inputs.tag-name }} \
        --version ${{ inputs.tag-name }}
        helm push "${{ inputs.ecr-repository-name }}-${{ inputs.tag-name }}.tgz" oci://$ECR_REGISTRY
      shell: bash

Upvotes: 1

Aziz Alfoudari
Aziz Alfoudari

Reputation: 5263

  1. Configure AWS credentials.
  2. Install helm.
  3. Authenticate with ECR:
aws ecr get-login-password \
     --region <aws-region> | helm registry login \
     --username AWS \
     --password-stdin <aws-account-id>.dkr.ecr.<aws-region>.amazonaws.com
  1. Push like you would for any other repository:
helm chart push <aws-account-id>.dkr.ecr.<aws-region>.amazonaws.com/<ecr-repo>:mychart

Upvotes: 0

Related Questions