Skip to content

Commit

Permalink
An option to regenerate charts index (related to aerokube#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
vania-pooh committed Dec 20, 2023
1 parent 6af7d75 commit fae189b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 5 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: build

on:
workflow_dispatch:
inputs:
regenerateIndex:
description: "Regenerate index from S3 archives"
required: false
push:
branches:
- master
Expand All @@ -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
Expand Down
15 changes: 13 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: release

on:
workflow_dispatch:
inputs:
regenerateIndex:
description: "Regenerate index from S3 archives"
required: false
release:
types: [published]

Expand All @@ -18,12 +23,18 @@ 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
run: aws s3 cp . --endpoint=${{ secrets.S3_ENDPOINT }} s3://${{ secrets.S3_BUCKET_NAME }} --recursive --acl public-read
env:
AWS_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.S3_REGION }}
AWS_DEFAULT_REGION: ${{ secrets.S3_REGION }}
16 changes: 14 additions & 2 deletions ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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

0 comments on commit fae189b

Please sign in to comment.