Skip to content

Create catalog proxy #8

Create catalog proxy

Create catalog proxy #8

Workflow file for this run

name: Create catalog proxy
on:
workflow_dispatch:
inputs:
catalog:
type: string
description: Source remote catalog file
default: list
extra_addons:
type: string
description: extra addons list (foo:4.0.0,tar:5.0.0-M01 comma seperated)
jobs:
catalog-proxy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Generate catalog
run: |
rawURL="https://raw.githubusercontent.com/${GITHUB_REPOSITORY}/${GITHUB_REF##*/}"
plfVersion=$(echo ${GITHUB_REF##*/} | grep -oP "^[0-9]+\.[0-9]+\.[0-9]+(-exo|-meed)?")
curl -fsSL http://storage.exoplatform.org/public/Addons/${{ inputs.catalog }}.json | jq ".[] | select(.compatibility==\"[${plfVersion}]\")" | jq -s > /tmp/filtredcatalog.json
echo ${{ inputs.extra_addons }} | tr ',' '\n' | while read _addon ; do
id=$(echo ${addon} | cut -d ':' -f1 )
version=$(echo ${addon} | cut -d ':' -f2 )
curl -fsSL http://storage.exoplatform.org/public/Addons/${{ inputs.catalog }}.json | jq ".[] | select((.id==\"${id}\") and (.version==\"${version}\"))" > /tmp/custcat.json
jq '. += $inputs' /tmp/filtredcatalog.json --slurpfile inputs /tmp/custcat.json | sponge /tmp/filtredcatalog.json
done
cp -f /tmp/filtredcatalog.json list.json
mkdir -p pkgs
for row in $(cat /tmp/filtredcatalog.json | jq -r '.[] | @base64'); do
_jq() {
echo ${row} | base64 --decode | jq -r ${1}
}
id=$(_jq '.id')
version=$(_jq '.version')
downloadUrl=$(_jq '.downloadUrl')
filename="${id}-${version}.zip"
rm "pkgs/${id}-${version}.zip" || true
wget $downloadUrl -O "pkgs/${id}-${version}.zip"
rawDownloadURL="${rawURL}/pkgs/${id}-${version}.zip"
sed -i "s|$downloadUrl|${rawDownloadURL}|g" list.json
done
rm -v /tmp/filtredcatalog.json
curl -fsSL http://patches.exoplatform.org/catalog.json | jq ".[] | select(.compatibility==\"[${plfVersion}]\")" | jq -s > /tmp/filtredcatalog.json
cp -f /tmp/filtredcatalog.json patch.json
mkdir -p patches
for row in $(cat /tmp/filtredcatalog.json | jq -r '.[] | @base64'); do
_jq() {
echo ${row} | base64 --decode | jq -r ${1}
}
id=$(_jq '.id')
version=$(_jq '.version')
downloadUrl=$(_jq '.downloadUrl')
filename="${id}-${version}.zip"
rm "patches/${id}-${version}.zip" || true
wget $downloadUrl -O "patches/${id}-${version}.zip"
rawDownloadURL="${rawURL}/patches/${id}-${version}.zip"
sed -i "s|$downloadUrl|${rawDownloadURL}|g" patch.json
done
git add .
git -c user.name="Patch Generator" -c user.email="hbenali.tn+bot@gmail.com" commit -m 'Generate catalog'
git push origin HEAD