Skip to content

Add Cloud Native Catalog Items #344

Add Cloud Native Catalog Items

Add Cloud Native Catalog Items #344

name: Add Cloud Native Catalog Items
on:
schedule:
- cron: "30 0 * * *"
workflow_dispatch:
repository_dispatch:
types: [add_catalog]
permissions:
contents: write
actions: read
jobs:
UpdateCloudNativeCatalog:
runs-on: ubuntu-22.04
outputs:
contentID: ${{ steps.update_catalog_patterns.outputs.contentID }}
steps:
- name: Checkout meshery.io repo
uses: actions/checkout@v4
with:
path: meshery.io
token: ${{ secrets.GH_ACCESS_TOKEN }}
- name: Checkout meshery/meshery repo
uses: actions/checkout@v4
with:
repository: meshery/meshery
path: meshery
token: ${{ secrets.GH_ACCESS_TOKEN }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: ./meshery.io/assets/artifact-hub-pkg/go.mod
- name: Set env
run: |
echo "MESHERY_CLOUD_BASE_URL=https://cloud.meshery.io" >> $GITHUB_ENV
echo "MESHERY_CATALOG_FILES_DIR=catalog" >> $GITHUB_ENV
- name: Cleanup
working-directory: ./meshery.io
run: |
find $MESHERY_CATALOG_FILES_DIR ! -name 'index.html' ! -name 'artifacthub-repo.yml' -maxdepth 1 -type f -delete
shopt -s nullglob
for dir in ./collections/_catalog/*/; do
find "$dir" -maxdepth 1 -type f -delete
done
- id: update_catalog_patterns
name: Update Catalog Patterns in Go
working-directory: ./meshery.io/assets/artifact-hub-pkg
run: |
go run package.go
env:
GH_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
# - name: Update Catalog Filters
# if: ${{ success() }}
# working-directory: ./meshery.io
# run: |
# catalogFilters=$(curl -sS "$MESHERY_CLOUD_BASE_URL/api/catalog/content/filter" 2>./err.txt)
# if [[ "$(<err.txt)" != "" ]]; then
# >&2 echo "Error connecting to Meshery Cloud"
# >&2 echo "$(<err.txt)"
# fi
# echo "$catalogFilters" | jq -r '.filters' > temp.json
# filterCount=$(echo "$catalogFilters" | jq '.total_count')
# 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=""
# echo "contentID=$designId" >> $GITHUB_OUTPUT
# # check if directory doesn't exists; then create it
# if [ ! -d "./collections/_filters/"$(echo $filterType | tr '[:upper:]' '[:lower:]')"" ]; then
# echo "$(echo $filterType | tr '[:upper:]' '[:lower:]') doesn't exist."
# echo "Creating directory...$(echo $filterType | tr '[:upper:]' '[:lower:]')"
# mkdir "./collections/_filters/"$(echo $filterType | tr '[:upper:]' '[:lower:]')""
# fi
# if [[ $filterInfo == "null" ]]; then
# filterInfo="\"\""
# fi
# if [[ $filterCaveats == "null" ]]; then
# filterCaveats="\"\""
# fi
# if [[ $filterType == "null" ]]; then
# patternType="wasm filter"
# fi
# compatLength=$(jq -r ".[$idx].catalog_data.compatibility | length" temp.json)
# for (( compatIdx=0; compatIdx<$compatLength; compatIdx++ ))
# do
# compatibility+="
# "
# compatibility+=" - $(jq -r ".[$idx].catalog_data.compatibility[$compatIdx]" temp.json)"
# 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 [[ "$(<err.txt)" != "" ]]; then
# >&2 echo "Error fetching User details"
# >&2 echo "$(<err.txt)"
# fi
# echo "$userInfo" > info.json
# userFullName="$(jq -r .first_name info.json) $(jq -r .last_name info.json)"
# userAvatarURL="$(jq -r .avatar_url info.json)"
# echo "---
# 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
# ---" > ./collections/_filters/"$(echo $filterType | tr '[:upper:]' '[:lower:]')"/$filterId.md
# done
# rm temp.json
- name: sync catalog directories to docs
run: |
rsync -av --delete meshery.io/collections/_catalog/ meshery/docs/catalog/
rsync -av --delete meshery.io/catalog/ meshery/docs/data/catalog/
- name: Pull latest changes from meshery/meshery
run: |
cd meshery
git pull origin master
- name: Commit changes to meshery/meshery repo
uses: stefanzweifel/git-auto-commit-action@v7
with:
repository: ./meshery
commit_user_name: meshery-ci
commit_user_email: ci@meshery.io
commit_options: "--signoff"
commit_message: "[Docs] Update _catalog collection"
branch: master
- name: Pull latest changes from meshery.io
run: |
cd meshery.io
git pull origin master
- name: Commit changes to meshery.io repo
uses: stefanzweifel/git-auto-commit-action@v7
with:
repository: ./meshery.io
commit_user_name: meshery-ci
commit_user_email: ci@meshery.io
commit_options: '--signoff'
commit_message: '[Catalog] Content Update'
branch: master
- name: Send Email on Workflow Failure
if: ${{ failure() }}
uses: dawidd6/action-send-mail@v7
with:
server_address: smtp.gmail.com
server_port: 465
username: ${{ secrets.MAIL_USERNAME }}
password: ${{ secrets.MAIL_PASSWORD }}
subject: GitHub Actions - Workflow Failure
from: "Catalog Workflow"
to: developers@meshery.io
body: |
Meshery's Add Cloud Native Catalog Items workflow failed.
Repository : ${{ github.repository }}
Branch : ${{ github.ref_name }}
Commit : ${{ github.sha }}
Event : ${{ github.event_name }}
Run : ${{ github.workflow }} / job ${{ github.job }} (run #${{ github.run_number }})
Actor : ${{ github.actor }}
Review the run logs: https://github.com/meshery/meshery.io/actions/runs/${{ github.run_id }}
The attached err.txt contains the captured error output.
attachments: err.txt