From fec90ca4ba84c4e476f52f104ce0cad53e9dd7db Mon Sep 17 00:00:00 2001 From: David Young Date: Thu, 30 May 2024 17:25:51 +1200 Subject: [PATCH] try pushing chart Signed-off-by: David Young --- .github/workflows/chart-push.yaml | 47 ++++++++++++++++ .github/workflows/charts-release-oci.yaml | 67 ----------------------- .github/workflows/charts-release.yaml | 52 ------------------ 3 files changed, 47 insertions(+), 119 deletions(-) create mode 100644 .github/workflows/chart-push.yaml delete mode 100644 .github/workflows/charts-release-oci.yaml delete mode 100644 .github/workflows/charts-release.yaml diff --git a/.github/workflows/chart-push.yaml b/.github/workflows/chart-push.yaml new file mode 100644 index 000000000..bbe501c46 --- /dev/null +++ b/.github/workflows/chart-push.yaml @@ -0,0 +1,47 @@ +name: "Charts: Release to GHCR OCI" + +on: + push: + paths: + - Chart.yaml + workflow_dispatch: + +permissions: + contents: read + packages: write + +env: + HELM_VERSION: 3.11.2 + CHARTS_SRC_DIR: "." + TARGET_REGISTRY: ghcr.io + TARGET_REPO: elfhosted/myprecious + +jobs: + release-charts: + name: Release charts + runs-on: ubuntu-latest + steps: + - name: Checkout chart sources + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + with: + fetch-depth: 0 + + - name: Install Kubernetes tools + uses: yokawasa/action-setup-kube-tools@v0.9.3 + with: + setup-tools: | + helm + yq + helm: "${{ env.HELM_VERSION }}" + + - name: Log into helm repo + shell: bash + run: | + helm registry login ghcr.io/elfhosted/charts -u ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} + + - name: Package & Push Helm Charts + shell: bash + run: | + CHART_VERSION=$(yq e '.version' Chart.yaml) + helm package . --dependency-update --destination . --version "${CHART_VERSION}" + helm push myprecious-${CHART_VERSION}.tgz" oci://${{ env.TARGET_REGISTRY }}/${{ env.TARGET_REPO }} diff --git a/.github/workflows/charts-release-oci.yaml b/.github/workflows/charts-release-oci.yaml deleted file mode 100644 index 32e875b3e..000000000 --- a/.github/workflows/charts-release-oci.yaml +++ /dev/null @@ -1,67 +0,0 @@ -name: "Charts: Release to GHCR OCI" - -on: - workflow_call: - inputs: - charts: - description: > - Json encoded list of Helm charts to release. - Defaults to releasing everything. - default: "[]" - required: false - type: string - -permissions: - contents: read - packages: write - -env: - HELM_VERSION: 3.11.2 - CHARTS_SRC_DIR: "." - TARGET_REGISTRY: ghcr.io - TARGET_REPO: elfhosted/myprecious - -jobs: - release-charts: - name: Release charts - runs-on: ubuntu-latest - steps: - - name: Checkout chart sources - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - with: - fetch-depth: 0 - - - name: Install Kubernetes tools - uses: yokawasa/action-setup-kube-tools@v0.9.3 - with: - setup-tools: | - helm - yq - helm: "${{ env.HELM_VERSION }}" - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ${{ env.TARGET_REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Log into helm repo - shell: bash - run: | - helm registry login ghcr.io/elfhosted/charts -u ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} - - - name: Package & Push Helm Charts - shell: bash - run: | - CHARTS=( $(yq --null-input e '${{ inputs.charts }}[]' ) ) - - for CHART in "${CHARTS[@]}" ; do - mapfile -t CHART_PATH_PARTS < <(echo "$CHART" | tr '/' '\n') - CHART_TYPE=${CHART_PATH_PARTS[0]} - CHART_NAME=${CHART_PATH_PARTS[1]} - CHART_VERSION=$(yq e '.version' ${{ env.CHARTS_SRC_DIR }}/${CHART}/Chart.yaml) - - helm package "${{ env.CHARTS_SRC_DIR }}/${CHART_TYPE}/${CHART_NAME}" --dependency-update --destination "${{ env.CHARTS_SRC_DIR }}/${CHART_TYPE}" --version "${CHART_VERSION}" - helm push "${{ env.CHARTS_SRC_DIR }}/${CHART_TYPE}/${CHART_NAME}-${CHART_VERSION}.tgz" oci://${{ env.TARGET_REGISTRY }}/${{ env.TARGET_REPO }} - done diff --git a/.github/workflows/charts-release.yaml b/.github/workflows/charts-release.yaml deleted file mode 100644 index a985280eb..000000000 --- a/.github/workflows/charts-release.yaml +++ /dev/null @@ -1,52 +0,0 @@ -name: "Charts: Release" - -concurrency: helm-release-oci - -on: - workflow_dispatch: - inputs: - charts: - description: > - Charts to release. Comma-separated string. - Defaults to releasing everything. - default: "" - required: false - - push: - branches: - - main - paths: - - "charts/**" - -env: - HELM_VERSION: 3.9.2 - -jobs: - prepare: - name: Prepare data required for release - runs-on: ubuntu-latest - outputs: - charts-to-release: ${{ steps.collect-charts.outputs.charts }} - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Collect charts to release - uses: bjw-s/helm-charts-actions/collect-charts@a60dc77aa47162c2b425202233165404e6923a7f - id: collect-charts - with: - repoConfigFile: ./.ci/repo-config.yaml - overrideCharts: "[${{ inputs.charts }}]" - - release-github-oci: - name: Release Application charts to GitHub Container Registry - uses: ./.github/workflows/charts-release-oci.yaml - needs: - - prepare - # - release-library-charts - with: - charts: "${{ needs.prepare.outputs.charts-to-release }}" - secrets: inherit - \ No newline at end of file