Skip to content

feat: post page through Telegra.ph #13

feat: post page through Telegra.ph

feat: post page through Telegra.ph #13

name: Pre Check Plugin
on:
pull_request:
types: [opened, synchronize, ready_for_review, review_requested, edited]
branches:
- main
- dev
paths-ignore:
- ".github/**"
- ".gitignore"
- "unpacked_plugin/**"
- "README.md"
- "LICENSE"
env:
REPO_NAME: langgenius/dify-plugins
jobs:
pre-check-plugin:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download Plugin Daemon
env:
GH_TOKEN: ${{ secrets.ORG_SCOPE_GITHUB_TOKEN }}
run: |
gh release download -R langgenius/dify-plugin-daemon --pattern "dify-plugin-linux-amd64" --dir .scripts
chmod +x .scripts/dify-plugin-linux-amd64
- name: Clone Marketplace Toolkit
env:
GH_TOKEN: ${{ secrets.ORG_SCOPE_GITHUB_TOKEN }}
run: |
gh repo clone https://github.com/langgenius/dify-marketplace-backend -- -b deploy/dev
cp -r dify-marketplace-backend/toolkit/* .scripts/
rm -rf dify-marketplace-backend
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.12.7
- name: Install Python Dependencies
run: |
python -m pip install --upgrade pip
pip install requests
- name: yq - portable yaml processor
uses: mikefarah/yq@v4.44.5
- name: Get PR Path
env:
GH_TOKEN: ${{ secrets.ORG_SCOPE_GITHUB_TOKEN }}
run: |
export PR_FILES=$(gh pr view -R ${{ env.REPO_NAME }} ${{ github.event.pull_request.number }} --json files --jq .files)
if PLUGIN_PATH=$(python3 .scripts/validator/check-pkg-paths.py); then
echo $PLUGIN_PATH
echo "PLUGIN_PATH=$PLUGIN_PATH" >> $GITHUB_ENV
else
echo "Only one .difypkg file change is allowed in a single PR."
exit 1
fi
- name: Unpack File
run: |
mv ${{ env.PLUGIN_PATH }} ${{ env.PLUGIN_PATH }}.zip
mkdir -p unpacked_plugin
unzip ${{ env.PLUGIN_PATH }}.zip -d unpacked_plugin
echo "PLUGIN_PATH=unpacked_plugin" >> $GITHUB_ENV
- name: Check Plugin Manifest
env:
GH_TOKEN: ${{ secrets.ORG_SCOPE_GITHUB_TOKEN }}
run: |
# manifest.yaml author must not be langgenius
if yq '.author' ${{ env.PLUGIN_PATH }}/manifest.yaml | grep -q "langgenius"; then
echo "!!! Plugin manifest.yaml author must not be 'langgenius'"
exit 1
fi
# author must equal to the pr author (lowercase)
if [ "$(yq '.author' ${{ env.PLUGIN_PATH }}/manifest.yaml)" != "$(gh pr view -R ${{ env.REPO_NAME }} ${{ github.event.pull_request.number }} --json author --jq .author.login | tr '[:upper:]' '[:lower:]')" ]; then
echo "!!! Plugin manifest.yaml author should be lowercase and must be the same as the PR author"
exit 1
fi
- name: Check If Version Exists
run: |
# get version, author, name
VERSION=$(yq '.version' ${{ env.PLUGIN_PATH }}/manifest.yaml)
AUTHOR=$(yq '.author' ${{ env.PLUGIN_PATH }}/manifest.yaml)
NAME=$(yq '.name' ${{ env.PLUGIN_PATH }}/manifest.yaml)
echo "Checking plugin version: $VERSION"
# Check if the version already exists
RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" "${{ secrets.MARKETPLACE_BASE_URL }}/api/v1/plugins/$AUTHOR/$NAME/$VERSION")
if [ "$RESPONSE_CODE" = "200" ]; then
RESPONSE=$(curl -s "${{ secrets.MARKETPLACE_BASE_URL }}/api/v1/plugins/$AUTHOR/$NAME/$VERSION")
if [ "$(echo "$RESPONSE" | jq -r '.code')" = "0" ]; then
echo "!!! Plugin version $VERSION already exists, please update the version number in manifest.yaml"
exit 1
fi
fi
- name: Check Plugin Deps
run: |
if [ -f ${{ env.PLUGIN_PATH }}/requirements.txt ]; then
echo "Trying to install plugin dependencies..."
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install -r ${{ env.PLUGIN_PATH }}/requirements.txt
deactivate
fi
- name: Check Plugin Install
run: |
if [ -f ${{ env.PLUGIN_PATH }}/requirements.txt ]; then
source .venv/bin/activate
fi
export INSTALL_METHOD=aws_lambda
python3 .scripts/validator/test-plugin-install.py -d ${{ env.PLUGIN_PATH }}
- name: Check Packaging
run: |
python3 .scripts/uploader/upload-package.py -d ${{ env.PLUGIN_PATH }} -t ${{ secrets.MARKETPLACE_TOKEN }} --plugin-daemon-path .scripts/dify-plugin-linux-amd64 -u ${{ secrets.MARKETPLACE_BASE_URL }} -f --test