Skip to content

Add Cloud Native Catalog Items #68

Add Cloud Native Catalog Items

Add Cloud Native Catalog Items #68

Workflow file for this run

name: Add Cloud Native Catalog Items

Check failure on line 1 in .github/workflows/add-catalog.yml

View workflow run for this annotation

GitHub Actions / Add Cloud Native Catalog Items

Invalid workflow file

The workflow is not valid. .github/workflows/add-catalog.yml: Expected stream end parse event
on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
repository_dispatch:
types: [add_catalog]
jobs:
UpdateCloudNativeCatalog:
runs-on: ubuntu-22.04
outputs:
contentID: ${{ steps.update_catalog_patterns.outputs.contentID }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_ACCESS_TOKEN }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21'
- name: Set env
run: |
echo "MESHERY_CLOUD_BASE_URL=https://meshery.layer5.io" >> $GITHUB_ENV
echo "MESHERY_CATALOG_FILES_DIR=catalog" >> $GITHUB_ENV
- name: Cleanup
run: |
find $MESHERY_CATALOG_FILES_DIR ! -name 'index.html' ! -name 'artifacthub-repo.yml' -maxdepth 1 -type f -delete
cd ./collections/_catalog
for dir in */; do find $dir -maxdepth 1 -type f -delete; done
cd ../../
- id: update_catalog_patterns
name: Update Catalog Patterns in Go
run: |
cd assets/artifact-hub-pkg
go run package.go
env:
GH_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
- name: Update Catalog Filters
if: ${{ success() }}
run: |
catalogFilters=$(curl -sS "$MESHERY_CLOUD_BASE_URL/api/catalog/content/filter" 2>./err.txt)
if [[ -s err.txt ]]; then
echo "Error connecting to Meshery Cloud" >&2
cat err.txt >&2
exit 1
fi
echo "$catalogFilters" | jq -r '.filters' > temp.json
filterCount=$(jq '.total_count' temp.json)
echo "Found $filterCount catalog filters"
for (( idx=0; idx<$filterCount; idx++ ))
do
filterId=$(jq -r .[$idx].id temp.json)
filterInfo=$(jq -r .[$idx].catalog_data.filter_info temp.json)
filterCaveats=$(jq -r .[$idx].catalog_data.filter_caveats temp.json)
filterType=$(jq -r .[$idx].catalog_data.type temp.json)
filterName=$(jq -r .[$idx].name temp.json)
filterImageURL=$(jq -r .[$idx].catalog_data.imageURL temp.json)
compatibility=""
# Normalize empty fields to prevent YAML errors
filterInfo=${filterInfo:-""}
filterCaveats=${filterCaveats:-""}
filterType=${filterType:-"wasm filter"}
compatLength=$(jq -r ".[$idx].catalog_data.compatibility | length" temp.json)
for (( compatIdx=0; compatIdx<$compatLength; compatIdx++ ))
do
compatibility+=" - $(jq -r ".[$idx].catalog_data.compatibility[$compatIdx]" temp.json)\n"
done
filterFile=$(jq -r .[$idx].filter_file temp.json)
echo "$filterFile" > $MESHERY_CATALOG_FILES_DIR/$filterId.yaml
userId=$(jq -r .[$idx].user_id temp.json)
userInfo=$(curl -sS "$MESHERY_CLOUD_BASE_URL/api/identity/users/profile/$userId" 2>>./err.txt)
if [[ -s err.txt ]]; then
echo "Error fetching User details" >&2
cat err.txt >&2
exit 1
fi
userFullName="$(jq -r .first_name info.json) $(jq -r .last_name info.json)"
userAvatarURL=$(jq -r .avatar_url info.json)
# Ensure directory exists
filterDir="./collections/_catalog/$(echo $filterType | tr '[:upper:]' '[:lower:]')"
mkdir -p "$filterDir"
# Write the catalog item to a markdown file
cat <<EOF > "$filterDir/$filterId.md"
---
layout: item
name: $filterName
userId: $userId
userName: $userFullName
userAvatarURL: $userAvatarURL
type: $filterType
compatibility: |
$compatibility
patternId: $filterId
image: /assets/images/webassembly_logo.svg
filterInfo: |
$filterInfo
filterCaveats: |
$filterCaveats
URL: 'https://raw.githubusercontent.com/meshery/meshery.io/master/$MESHERY_CATALOG_FILES_DIR/$filterId.yaml'
downloadLink: $filterId.yaml
---
EOF
done
rm temp.json
- name: Pull changes from remote
run: git pull origin master
- name: Commit
uses: stefanzweifel/git-auto-commit-action@v4
with:
file_pattern: catalog/* collections/_catalog/*
commit_user_name: l5io
commit_user_email: [email protected]
commit_author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
commit_options: '--signoff'
commit_message: '[Catalog] Update Catalog items'
- name: Send Email on Workflow Failure
if: ${{ failure() }}
uses: dawidd6/[email protected]
with:
server_address: smtp.gmail.com
server_port: 465
username: ${{ secrets.MAIL_USERNAME }}
password: ${{ secrets.MAIL_PASSWORD }}
subject: GitHub Actions - Workflow Failure
from: |
"Catalog Update Workflow" <[email protected]>
to: [email protected]
body: |
Meshery's Add Cloud Native Catalog Items <a href="https://github.com/meshery/meshery.io/actions/workflows/add-catalog.yml">workflow</a> encountered error(s). Refer to the attached error log for details or review the [results of the failed workflow](https://github.com/meshery/meshery.io/actions/runs/${{ github.run_id }}).
attachments: err.txt