From 814c80eff887ed032a55021a64a84279d9ef1695 Mon Sep 17 00:00:00 2001 From: Darren <27513732@qq.com> Date: Fri, 8 Dec 2023 12:02:48 +0800 Subject: [PATCH] optimize media yml --- .github/workflows/docker.yml | 2 + .github/workflows/media.yml | 76 ++++++++++++++++++++++++++++++++++++ build/README.md | 3 ++ docker/apphub/Dockerfile | 6 +-- media/README.md | 3 ++ media/media.json | 13 ++++++ version.json | 4 ++ 7 files changed, 104 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/media.yml create mode 100644 build/README.md create mode 100644 media/README.md create mode 100644 media/media.json diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 1604daa8..50c05fad 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -69,6 +69,8 @@ jobs: echo "DIRECTORY=docker/$APP" >> $GITHUB_ENV echo "README=docker/$APP/README.md" >> $GITHUB_ENV + + - name: Build & push Docker image uses: mr-smithers-excellent/docker-build-push@v6 with: diff --git a/.github/workflows/media.yml b/.github/workflows/media.yml new file mode 100644 index 00000000..1625b9ee --- /dev/null +++ b/.github/workflows/media.yml @@ -0,0 +1,76 @@ +name: Buidl media for apphub image + +on: + workflow_dispatch: + +jobs: + Build_New_Version_For_Release: + runs-on: ubuntu-latest + env: + ACCESS_TOKEN: ${{ secrets.CONTENTFUL_GRAPHQLTOKEN }} + LOCALES: "en-US,zh-CN" + DATA_DIR: "json" + APPSTORE_LOGO_DIR: "logos" + SCREENSHOT_DIR: "screenshots" + LIMIT: 100 + CI: false + + steps: + - uses: actions/checkout@v2 + + - name: Install GNU Parallel + run: sudo apt-get install -y parallel + + - name: Fetch catalog data from contentful graphql + run: | + mkdir -p $DATA_DIR + IFS=',' read -ra LOCALE_ARRAY <<< "$LOCALES" + for LOCALE in "${LOCALE_ARRAY[@]}"; do + curl -X POST \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $ACCESS_TOKEN" \ + -d '{"query":"query($locale: String){catalog(id: \"2Yp0TY3kBHgG6VDjsHZNpK\",locale:$locale) {linkedFrom(allowedLocales:[\"en-US\"]) {catalogCollection(limit:20) {items {key position title linkedFrom(allowedLocales:[\"en-US\"]) {catalogCollection(limit:20) {items {key title position}}}}}}}}","variables":{"locale":"'$LOCALE'"}}' \ + https://graphql.contentful.com/content/v1/spaces/ffrhttfighww | \ + jq '.data.catalog.linkedFrom.catalogCollection.items' > $DATA_DIR/catalog_${LOCALE:0:2}.json + done + + - name: Fetch product data json and download screenshots + run: | + mkdir -p $SCREENSHOT_DIR && IFS=',' read -ra LOCALE_ARRAY <<< "$LOCALES" && for LOCALE in "${LOCALE_ARRAY[@]}"; do + SKIP=0 + TOTAL=0 + ITEMS=() + while [ $SKIP -le $TOTAL ]; do + RESPONSE=$(curl -X POST \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $ACCESS_TOKEN" \ + -d '{"query":"query($locale: String,$skip: Int){productCollection(locale:$locale,where:{appStore:true,production:true},limit: '$LIMIT', skip: $skip) {total items {sys {id} key hot trademark summary overview websiteurl description screenshots distribution vcpu memory storage logo {imageurl} catalogCollection(limit:15) {items {key title catalogCollection(limit:5){items{key title}}}}}}}", "variables":{"locale":"'$LOCALE'", "skip":'$SKIP'}}' \ + https://graphql.contentful.com/content/v1/spaces/ffrhttfighww) + ITEMS+=($(echo $RESPONSE | jq '.data.productCollection.items[]')) + TOTAL=$(echo $RESPONSE | jq '.data.productCollection.total') + SKIP=$((SKIP + LIMIT)) + done + echo ${ITEMS[@]} | jq -r '.screenshots[]?.value' | sed 's/"//g' | parallel -j 10 "wget -t 0 -N {} -P $SCREENSHOT_DIR/${LOCALE:0:2} || echo {} >> $SCREENSHOT_DIR/Error.log" + echo ${ITEMS[@]} | jq -s '.' > $DATA_DIR/product_${LOCALE:0:2}.json + done + + - name: Install ossutil + run: | + wget http://gosspublic.alicdn.com/ossutil/1.7.6/ossutil64 + chmod 755 ossutil64 + - name: Configure ossutil + run: ./ossutil64 config -e ${{ secrets.OSS_ENDPOINT }} -i ${{ secrets.OSS_ACCESS_KEY_ID }} -k ${{ secrets.OSS_ACCESS_KEY_SECRET }} + + - name: Download logos from oss + run: ./ossutil64 cp oss://libs-websoft9-com/Websoft9/logo/product/ $APPSTORE_LOGO_DIR -r --update + + - name: Create Zip Archive + run: | + rsync -av json logos screenshots docs media + zip -r media.zip media/ + + - name: Upload media.zip to artifacts + uses: actions/upload-artifact@v2 + with: + name: media + path: media.zip \ No newline at end of file diff --git a/build/README.md b/build/README.md new file mode 100644 index 00000000..20a5c021 --- /dev/null +++ b/build/README.md @@ -0,0 +1,3 @@ +# Build + +Build scripts for DevOps \ No newline at end of file diff --git a/docker/apphub/Dockerfile b/docker/apphub/Dockerfile index 1a4b66fb..f91da135 100644 --- a/docker/apphub/Dockerfile +++ b/docker/apphub/Dockerfile @@ -15,10 +15,10 @@ ENV source_github_pages="https://websoft9.github.io/websoft9" RUN apt update && apt install -y --no-install-recommends curl git jq cron iproute2 supervisor rsync wget unzip zip && \ # Prepare source files - wget $docker_library_repo/archive/refs/tags/$LIBRARY_VERSION.zip -O ./library.zip && \ - unzip library.zip && \ - mv docker-library-* w9library && \ + git clone --depth=1 $docker_library + mv docker-library w9library && \ rm -rf w9library/.github && \ + wget $media_repo/archive/refs/tags/$MEDIA_VERSION.zip -O ./media.zip && \ unzip media.zip && \ mv media-* w9media && \ diff --git a/media/README.md b/media/README.md new file mode 100644 index 00000000..5e40c991 --- /dev/null +++ b/media/README.md @@ -0,0 +1,3 @@ +# media + +Wesoft9 application Logos, data and Screen shoot \ No newline at end of file diff --git a/media/media.json b/media/media.json new file mode 100644 index 00000000..c0fee121 --- /dev/null +++ b/media/media.json @@ -0,0 +1,13 @@ +{ + "Plugin Name": "Media", + "Repository": "https://github.com/Websoft9/plugin-media", + "Update URI": "https://example.com/my-plugin/", + "Description": "Wesoft9 application Logos, data and Screen shoot.", + "Version": "0.0.7", + "Requires at most": "1.9.0", + "Requires at least": "0.0.2", + "Author": "Websoft9 Inc", + "Author URI": "https://www.websoft9.com/", + "License": "GPL v2 or later", + "License URI": "https://www.gnu.org/licenses/gpl-2.0.html" +} \ No newline at end of file diff --git a/version.json b/version.json index 53f07854..735bec62 100644 --- a/version.json +++ b/version.json @@ -9,6 +9,10 @@ "settings": "0.0.8", "navigator": "0.5.10" }, + "data": { + "media": "0.0.7", + "library": "0.5.19-rc1" + }, "OS": { "Fedora": [ "38",