From fae189b8e60407496d491bd50567d6920445c1d5 Mon Sep 17 00:00:00 2001 From: Ivan Krutov Date: Wed, 20 Dec 2023 15:19:00 +0300 Subject: [PATCH] An option to regenerate charts index (related to #231) --- .github/workflows/build.yml | 13 ++++++++++++- .github/workflows/release.yml | 15 +++++++++++++-- ci/build.sh | 16 ++++++++++++++-- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f93ebd3..fb79dba 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,11 @@ name: build on: + workflow_dispatch: + inputs: + regenerateIndex: + description: "Regenerate index from S3 archives" + required: false push: branches: - master @@ -19,7 +24,13 @@ jobs: run: | git fetch --tags export COMMIT=$(git rev-parse --short HEAD) - ci/build.sh $COMMIT unstable + ci/build.sh $COMMIT ${{ github.event.inputs.regenerateIndex }} unstable + env: + S3_ENDPOINT: ${{ secrets.S3_ENDPOINT }} + S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }} + AWS_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_KEY }} + AWS_DEFAULT_REGION: ${{ secrets.S3_REGION }} - name: Send output to S3 bucket working-directory: ./output diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b562766..8cfdaa3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,11 @@ name: release on: + workflow_dispatch: + inputs: + regenerateIndex: + description: "Regenerate index from S3 archives" + required: false release: types: [published] @@ -18,7 +23,13 @@ jobs: run: echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV - name: Build - run: ci/build.sh $RELEASE_VERSION + run: ci/build.sh $RELEASE_VERSION ${{ github.event.inputs.regenerateIndex }} + env: + S3_ENDPOINT: ${{ secrets.S3_ENDPOINT }} + S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }} + AWS_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_KEY }} + AWS_DEFAULT_REGION: ${{ secrets.S3_REGION }} - name: Send output to S3 bucket working-directory: ./output @@ -26,4 +37,4 @@ jobs: env: AWS_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY }} AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_KEY }} - AWS_DEFAULT_REGION: ${{ secrets.S3_REGION }} \ No newline at end of file + AWS_DEFAULT_REGION: ${{ secrets.S3_REGION }} diff --git a/ci/build.sh b/ci/build.sh index 7b2bb8b..7ff46a1 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -5,7 +5,8 @@ set -e CHARTS_REPO="https://charts.aerokube.com/" commit=$1 -path=${2:-""} +regenerate=${2:-""} +path=${3:-""} output_dir="output" if [ -n "$path" ]; then output_dir="$output_dir/$path" @@ -22,5 +23,16 @@ for package in moon moon2 browser-ops license-ops boot; do helm package "$package" --destination "$output_dir" --version "$version" done cd "$output_dir" -wget -O index.yaml "$CHARTS_REPO/index.yaml" +if [ -n "$regenerate" ] -a [ "$regenerate" == "true" ]; then + regenerateDir="regenerate" + mkdir -p "$regenerateDir" + pushd "$regenerateDir" + aws s3 cp "s3://$S3_BUCKET_NAME" . --endpoint="$S3_ENDPOINT" + helm repo index . --url "$CHARTS_REPO" + popd + cp regenerate/index.yaml . + rm -Rf "$regenerateDir" +else + wget -O index.yaml "$CHARTS_REPO/index.yaml" +fi helm repo index . --url "$CHARTS_REPO" --merge index.yaml