forked from containers/nri-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Feruzjon Muyassarov <feruzjon.muyassarov@intel.com>
- Loading branch information
1 parent
46dff5d
commit 93bda9c
Showing
6 changed files
with
69 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Publish Helm charts | ||
|
||
on: | ||
release: | ||
types: | ||
- published | ||
|
||
jobs: | ||
release: | ||
concurrency: | ||
group: ${{ github.event.release.tag_name }} | ||
cancel-in-progress: false | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
ref: main | ||
|
||
- name: Install Helm | ||
uses: azure/setup-helm@v3 | ||
|
||
- name: Run chart publisher script | ||
run: ./scripts/build/helm-publisher.sh ${{ join(github.event.release.assets.*.browser_download_url, ' ') }} | ||
shell: bash | ||
|
||
- name: Push | ||
shell: bash | ||
run: | | ||
git push https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git gh-pages | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,40 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
owner="fmuyassarov" | ||
repo="nri-plugins" | ||
index_file="index.yaml" | ||
browser_download_url="$@" | ||
|
||
# Fetch browser download URLs for releases | ||
releases=$(curl -s "https://api.github.com/repos/$owner/$repo/releases" | jq -r '.[].assets[].browser_download_url') | ||
git checkout gh-pages | ||
|
||
# Check if index.yaml exists, if not create it | ||
if [ ! -f "$index_file" ]; then | ||
touch "$index_file" | ||
fi | ||
# Verify if the release assets include Helm chart packages. If they do, | ||
# we can proceed with updating the index.yaml file, otherwise throw an error. | ||
charts_urls=$(echo "$browser_download_url" | grep '.*helm-chart-.*.tgz') | ||
|
||
# Check if releases were found | ||
if [ -n "$releases" ]; then | ||
# Check if Helm release assets were found | ||
if [ -n "$charts_urls" ]; then | ||
# Loop through the URLs | ||
for url in $releases; do | ||
for chart in $charts_urls; do | ||
# Check if the URL path exists in index.yaml | ||
# and if not, update the index.yaml accordingly | ||
if ! grep -q "$url" "$index_file"; then | ||
wget "$url" | ||
base_url=$(dirname "$url") | ||
if ! grep -q "$chart" "$index_file"; then | ||
wget "$chart" | ||
base_url=$(dirname "$chart") | ||
if ! helm repo index . --url "$base_url" --merge "$index_file"; then | ||
echo "Failed to update "$index_file" for: $base_url" | ||
fi | ||
rm nri-resource-policy-*.tgz | ||
fi | ||
done | ||
else | ||
echo "No releases found. Exiting..." | ||
echo "No Helm packages were found in the release: $RELEASE_VERSION" | ||
exit 1 | ||
fi | ||
|
||
# Create a new commit | ||
release=$(basename "$download_baseurl") | ||
commit_msg="Update Helm index for release $release" | ||
|
||
echo "Committing changes..." | ||
|
||
git commit -m "$commit_msg" -- index.yaml | ||
|
||
echo "gh-pages branch successfully updated" |