Skip to content

Commit

Permalink
ci: release charts to ACR (#154)
Browse files Browse the repository at this point in the history
* ci: release charts to ACR

* fix: sleep 5min to wait for deployment of GitHub Pages
  • Loading branch information
zyy17 authored Aug 13, 2024
1 parent 478c631 commit 326a753
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 5 deletions.
33 changes: 28 additions & 5 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

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

- name: Run chart-releaser
uses: helm/[email protected]
Expand All @@ -35,14 +33,39 @@ 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]

- 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:
# TODO(zyy17): Maybe it's not a elegant way to wait for GitHub Pages to update. For many scenarios, waiting for 5 minutes is enough.
- name: Wait for deployment of GitHub Pages
run: |
sleep 300
- 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"
fi
done

0 comments on commit 326a753

Please sign in to comment.