diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 1fd3c1c..bb406c8 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -73,3 +73,40 @@ jobs: env: CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" CR_SKIP_EXISTING: true + + publish-ecr: + if: github.ref == 'refs/heads/main' + needs: test + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + env: + AWS_REGION: eu-central-1 + steps: + - name: Checkout + uses: actions/checkout@v7 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v6 + with: + role-to-assume: ${{ vars.AWS_ASSUME_ROLE_ARN_CUSTOM }} + aws-region: ${{ env.AWS_REGION }} + + - name: Publish charts to ECR + run: | + REGISTRY="$(aws sts get-caller-identity --query Account --output text).dkr.ecr.$AWS_REGION.amazonaws.com" + aws ecr get-login-password | helm registry login --username AWS --password-stdin "$REGISTRY" + for dir in parcellab/*/; do + name="$(yq .name "$dir/Chart.yaml")" + version="$(yq .version "$dir/Chart.yaml")" + aws ecr describe-repositories --repository-names "charts/$name" >/dev/null 2>&1 || \ + aws ecr create-repository --repository-name "charts/$name" --image-tag-mutability IMMUTABLE + # Helm stores "+" in versions as "_" in OCI tags + if aws ecr describe-images --repository-name "charts/$name" --image-ids imageTag="${version//+/_}" >/dev/null 2>&1; then + echo "Skipping $name $version, already in ECR" + continue + fi + helm package --dependency-update "$dir" --destination .packages + helm push ".packages/$name-$version.tgz" "oci://$REGISTRY/charts" + done