Skip to content

Commit

Permalink
ci: release charts to ACR
Browse files Browse the repository at this point in the history
  • Loading branch information
zyy17 committed Aug 12, 2024
1 parent 478c631 commit d89925b
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 3 deletions.
38 changes: 35 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
name: Release Charts

on:
pull_request:
types: [ opened, synchronize, reopened, ready_for_review ]
paths-ignore:
- 'docs/**'
- '**.md'
- '.gitignore'
push:
branches:
- main
paths-ignore:
- 'docs/**'
- '**.md'
- '.gitignore'
workflow_dispatch:

jobs:
Expand All @@ -13,7 +23,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -23,7 +33,7 @@ jobs:
git config user.email "[email protected]"
- name: Install Helm
uses: azure/setup-helm@v3
uses: azure/setup-helm@v4.2.0
with:
version: v3.12.1

Expand All @@ -35,14 +45,36 @@ jobs:
CR_SKIP_EXISTING: true
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

release-charts-to-acr:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4

- name: Set up Helm
uses: azure/[email protected]
with:
version: v3.12.1

- name: Login to OCI Registry
run: echo '${{ secrets.ALICLOUD_PASSWORD }}' | helm registry login ${{ vars.OCI_REGISTRY_URL }} -u ${{ secrets.ALICLOUD_USERNAME }} --password-stdin

- name: Package and Push Helm Charts
shell: bash
env:
OCI_REGISTRY_URL: ${{ vars.OCI_REGISTRY_URL }}
OCI_NAMESPACE: ${{ vars.OCI_NAMESPACE }}
run: |
./scripts/release-charts-to-acr.sh
release-charts-to-s3:
needs: [
release,
]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
24 changes: 24 additions & 0 deletions scripts/release-charts-to-acr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

OCI_REGISTRY_URL=${OCI_REGISTRY_URL:-"greptime-registry.cn-hangzhou.cr.aliyuncs.com"}
OCI_NAMESPACE=${OCI_NAMESPACE:-"charts"}
CHARTS_DIR="charts"

for dir in "$CHARTS_DIR"/*/; do
# Ensure the directory exists and is not empty.
if [ -d "$dir" ]; then
# Get the chart name from the directory path.
chart_name=$(basename "$dir")

# Package the chart, specifying the directory and output path directly.
helm package "$dir" --destination "$dir"

# Get the packaged chart file path.
packaged_file=$(find "$dir" -type f -name "*.tgz")

echo "Package $chart_name to $packaged_file and push to oci://$OCI_REGISTRY_URL/$OCI_NAMESPACE/$chart_name ..."

# Push the packaged chart to the OCI repository, handling the output path.
helm push "${packaged_file}" "oci://$OCI_REGISTRY_URL/$OCI_NAMESPACE/$chart_name"
fi
done

0 comments on commit d89925b

Please sign in to comment.