Dify
English
English
  • Getting Started
    • Welcome to Dify
      • Features and Specifications
      • List of Model Providers
    • Dify Community
      • Deploy with Docker Compose
      • Start with Local Source Code
      • Deploy with aaPanel
      • Start Frontend Docker Container Separately
      • Environment Variables Explanation
      • FAQs
    • Dify Cloud
    • Dify Premium on AWS
    • Dify for Education
  • Guides
    • Model
      • Add New Provider
      • Predefined Model Integration
      • Custom Model Integration
      • Interfaces
      • Schema
      • Load Balancing
    • Application Orchestration
      • Create Application
      • Chatbot Application
        • Multiple Model Debugging
      • Agent
      • Application Toolkits
        • Moderation Tool
    • Workflow
      • Key Concepts
      • Variables
      • Node Description
        • Start
        • End
        • Answer
        • LLM
        • Knowledge Retrieval
        • Question Classifier
        • Conditional Branch IF/ELSE
        • Code Execution
        • Template
        • Doc Extractor
        • List Operator
        • Variable Aggregator
        • Variable Assigner
        • Iteration
        • Parameter Extraction
        • HTTP Request
        • Agent
        • Tools
        • Loop
      • Shortcut Key
      • Orchestrate Node
      • File Upload
      • Error Handling
        • Predefined Error Handling Logic
        • Error Type
      • Additional Features
      • Debug and Preview
        • Preview and Run
        • Step Run
        • Conversation/Run Logs
        • Checklist
        • Run History
      • Application Publishing
      • Structured Outputs
      • Bulletin: Image Upload Replaced by File Upload
    • Knowledge
      • Create Knowledge
        • 1. Import Text Data
          • 1.1 Import Data from Notion
          • 1.2 Import Data from Website
        • 2. Choose a Chunk Mode
        • 3. Select the Indexing Method and Retrieval Setting
      • Manage Knowledge
        • Maintain Documents
        • Maintain Knowledge via API
      • Metadata
      • Integrate Knowledge Base within Application
      • Retrieval Test / Citation and Attributions
      • Knowledge Request Rate Limit
      • Connect to an External Knowledge Base
      • External Knowledge API
    • Tools
      • Quick Tool Integration
      • Advanced Tool Integration
      • Tool Configuration
        • Google
        • Bing
        • SearchApi
        • StableDiffusion
        • Dall-e
        • Perplexity Search
        • AlphaVantage
        • Youtube
        • SearXNG
        • Serper
        • SiliconFlow (Flux AI Supported)
        • ComfyUI
    • Publishing
      • Publish as a Single-page Web App
        • Web App Settings
        • Text Generator Application
        • Conversation Application
      • Embedding In Websites
      • Developing with APIs
      • Re-develop Based on Frontend Templates
    • Annotation
      • Logs and Annotation
      • Annotation Reply
    • Monitoring
      • Data Analysis
      • Integrate External Ops Tools
        • Integrate LangSmith
        • Integrate Langfuse
        • Integrate Opik
    • Extension
      • API-Based Extension
        • External Data Tool
        • Deploy API Tools with Cloudflare Workers
        • Moderation
      • Code-Based Extension
        • External Data Tool
        • Moderation
    • Collaboration
      • Discover
      • Invite and Manage Members
    • Management
      • App Management
      • Team Members Management
      • Personal Account Management
      • Subscription Management
      • Version Control
  • Workshop
    • Basic
      • How to Build an AI Image Generation App
    • Intermediate
      • Build An Article Reader Using File Upload
      • Building a Smart Customer Service Bot Using a Knowledge Base
      • Generating analysis of Twitter account using Chatflow Agent
  • Community
    • Seek Support
    • Become a Contributor
    • Contributing to Dify Documentation
  • Plugins
    • Introduction
    • Quick Start
      • Install and Use Plugins
      • Develop Plugins
        • Initialize Development Tools
        • Tool Plugin
        • Model Plugin
          • Create Model Providers
          • Integrate the Predefined Model
          • Integrate the Customizable Model
        • Agent Strategy Plugin
        • Extension Plugin
        • Bundle
      • Debug Plugin
    • Manage Plugins
    • Schema Specification
      • Manifest
      • Endpoint
      • Tool
      • Agent
      • Model
        • Model Designing Rules
        • Model Schema
      • General Specifications
      • Persistent Storage
      • Reverse Invocation of the Dify Service
        • App
        • Model
        • Tool
        • Node
    • Best Practice
      • Develop a Slack Bot Plugin
      • Dify MCP Plugin Guide: Connect Zapier and Automate Email Delivery with Ease
    • Publish Plugins
      • Publish Plugins Automatically
      • Publish to Dify Marketplace
        • Plugin Developer Guidelines
        • Plugin Privacy Protection Guidelines
      • Publish to Your Personal GitHub Repository
      • Package the Plugin File and Publish it
      • Signing Plugins for Third-Party Signature Verification
    • FAQ
  • Development
    • Backend
      • DifySandbox
        • Contribution Guide
    • Models Integration
      • Integrate Open Source Models from Hugging Face
      • Integrate Open Source Models from Replicate
      • Integrate Local Models Deployed by Xinference
      • Integrate Local Models Deployed by OpenLLM
      • Integrate Local Models Deployed by LocalAI
      • Integrate Local Models Deployed by Ollama
      • Integrate Models on LiteLLM Proxy
      • Integrating with GPUStack for Local Model Deployment
      • Integrating AWS Bedrock Models (DeepSeek)
    • Migration
      • Migrating Community Edition to v1.0.0
  • Learn More
    • Use Cases
      • DeepSeek & Dify Integration Guide: Building AI Applications with Multi-Turn Reasoning
      • Private Deployment of Ollama + DeepSeek + Dify: Build Your Own AI Assistant
      • Build a Notion AI Assistant
      • Create a MidJourney Prompt Bot with Dify
      • Create an AI Chatbot with Business Data in Minutes
      • Integrating Dify Chatbot into Your Wix Website
      • How to connect with AWS Bedrock Knowledge Base?
      • Building the Dify Scheduler
      • Building an AI Thesis Slack Bot on Dify
    • Extended Reading
      • What is LLMOps?
      • Retrieval-Augmented Generation (RAG)
        • Hybrid Search
        • Re-ranking
        • Retrieval Modes
      • How to Use JSON Schema Output in Dify?
    • FAQ
      • Self-Host
      • LLM Configuration and Usage
      • Plugins
  • Policies
    • Open Source License
    • User Agreement
      • Terms of Service
      • Privacy Policy
      • Get Compliance Report
  • Features
    • Workflow
Powered by GitBook
On this page
  • Background
  • Concepts
  • Prerequisites
  • Parameters and Configuration
  • Step-by-Step Guide
  • Usage Guide
  • Outcome
  • Example Repository
  1. Plugins
  2. Publish Plugins

Publish Plugins Automatically

PreviousPublish PluginsNextPublish to Dify Marketplace

Last updated 2 months ago

Background

Updating plugins that others are actively using can be tedious. Traditionally, you would need to modify code, bump versions, push changes, create branches, package files, and submit PRs manually - a repetitive process that slows down development.

Thus, we have created Plugin Auto-PR, a GitHub Actions workflow that automates the entire process. Now you can package, push, and create PRs with a single action, focusing on building great plugins.

Concepts

GitHub Actions

GitHub Actions automates your development tasks in GitHub.

How it works: When triggered (e.g., by a code push), it runs your workflow in a cloud-based virtual machine, handling everything from build to deployment automatically.

Workflow

Limits:

  • Public repositories: Unlimited

  • Private repositories: 2000 minutes per month

Plugin Auto-PR

How it works:

  1. Workflow triggers when you push code to the main branch of your plugin source repository

  2. Workflow reads plugin information from the manifest.yaml file

  3. Automatically packages the plugin as a .difypkg file

  4. Pushes the packaged file to your forked dify-plugins repository

  5. Creates a new branch and commits changes

  6. Automatically creates a PR to merge into the upstream repository

Prerequisites

Repository

  • You already have your own plugin source code repository (e.g., your-name/plugin-source)

  • You already have your own forked plugin repository (e.g., your-name/dify-plugins)

  • Your forked repository already has the plugin directory structure:

dify-plugins/
└── your-author-name
    └── plugin-name

Permission

This workflow requires appropriate permissions to function:

  • You need to create a GitHub Personal Access Token (PAT) with sufficient permissions

  • The PAT must have permission to push code to your forked repository

  • The PAT must have permission to create PRs to the upstream repository

Parameters and Configuration

Setup Requirements

To get started with auto-publishing, you will need two key components:

manifest.yaml file: This file drives the automation process:

  • name: Your plugin’s name (affects package and branch names)

  • version: Semantic version number (increment with each release)

  • author: Your GitHub username (determines repository paths)

PLUGIN_ACTION Secret: You need to add this secret to your plugin source repository:

  • Value: Must be a Personal Access Token (PAT) with sufficient permissions

  • Permission: Ability to push branches to your forked repository and create PRs to the upstream repository

Automatically-Generated Parameters

Once set up, the workflow automatically handles these parameters:

  • GitHub username: Read from the author field in manifest.yaml

  • Author folder name: Consistent with the author field

  • Plugin name: Read from the name field in manifest.yaml

  • Branch name: bump-{plugin-name}-plugin-{version}

  • Package filename: {plugin-name}-{version}.difypkg

  • PR title and content: Automatically generated based on plugin name and version

Step-by-Step Guide

1

Prepare Repositories

Ensure you have forked the official dify-plugins repository and have your own plugin source repository.

2

Configure Secret

Navigate to your plugin source repository, click Settings > Secrets and variables > Actions > New repository secret, and create a GitHub Secret:

  • Name: PLUGIN_ACTION

  • Value: GitHub Personal Access Token (PAT) with write permissions to the target repository (your-name/dify-plugins)

3

Create Workflow File

Create a .github/workflows/ directory in your repository, create a file named plugin-publish.yml in this directory, and copy the following content into the file:

# .github/workflows/auto-pr.yml
name: Auto Create PR on Main Push

on:
  push:
    branches: [ main ]  # Trigger on push to main

jobs:
  create_pr: # Renamed job for clarity
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Print working directory # Kept for debugging
        run: |
          pwd
          ls -la

      - name: Download CLI tool
        run: |
          # Create bin directory in runner temp
          mkdir -p $RUNNER_TEMP/bin
          cd $RUNNER_TEMP/bin

          # Download CLI tool
          wget https://github.com/langgenius/dify-plugin-daemon/releases/download/0.0.6/dify-plugin-linux-amd64
          chmod +x dify-plugin-linux-amd64

          # Show download location and file
          echo "CLI tool location:"
          pwd
          ls -la dify-plugin-linux-amd64

      - name: Get basic info from manifest # Changed step name and content
        id: get_basic_info
        run: |
          PLUGIN_NAME=$(grep "^name:" manifest.yaml | cut -d' ' -f2)
          echo "Plugin name: $PLUGIN_NAME"
          echo "plugin_name=$PLUGIN_NAME" >> $GITHUB_OUTPUT

          VERSION=$(grep "^version:" manifest.yaml | cut -d' ' -f2)
          echo "Plugin version: $VERSION"
          echo "version=$VERSION" >> $GITHUB_OUTPUT

          # If the author's name is not your github username, you can change the author here
          AUTHOR=$(grep "^author:" manifest.yaml | cut -d' ' -f2)
          echo "Plugin author: $AUTHOR"
          echo "author=$AUTHOR" >> $GITHUB_OUTPUT

      - name: Package Plugin
        id: package
        run: |
          # Use the downloaded CLI tool to package
          cd $GITHUB_WORKSPACE
          # Use variables for package name
          PACKAGE_NAME="${{ steps.get_basic_info.outputs.plugin_name }}-${{ steps.get_basic_info.outputs.version }}.difypkg"
          # Use CLI from runner temp
          $RUNNER_TEMP/bin/dify-plugin-linux-amd64 plugin package . -o "$PACKAGE_NAME"

          # Show packaging result
          echo "Package result:"
          ls -la "$PACKAGE_NAME"
          echo "package_name=$PACKAGE_NAME" >> $GITHUB_OUTPUT

          # Show full file path and directory structure (kept for debugging)
          echo "\\nFull file path:"
          pwd
          echo "\\nDirectory structure:"
          tree || ls -R

      - name: Checkout target repo
        uses: actions/checkout@v3
        with:
          # Use author variable for repository
          repository: ${{steps.get_basic_info.outputs.author}}/dify-plugins
          path: dify-plugins
          token: ${{ secrets.PLUGIN_ACTION }}
          fetch-depth: 1 # Fetch only the last commit to speed up checkout
          persist-credentials: true # Persist credentials for subsequent git operations

      - name: Prepare and create PR
        run: |
          # Debug info (kept)
          echo "Debug: Current directory $(pwd)"
          # Use variable for package name
          PACKAGE_NAME="${{ steps.get_basic_info.outputs.plugin_name }}-${{ steps.get_basic_info.outputs.version }}.difypkg"
          echo "Debug: Package name: $PACKAGE_NAME"
          ls -la

          # Move the packaged file to the target directory using variables
          mkdir -p dify-plugins/${{ steps.get_basic_info.outputs.author }}/${{ steps.get_basic_info.outputs.plugin_name }}
          mv "$PACKAGE_NAME" dify-plugins/${{ steps.get_basic_info.outputs.author }}/${{ steps.get_basic_info.outputs.plugin_name }}/

          # Enter the target repository directory
          cd dify-plugins

          # Configure git
          git config user.name "GitHub Actions"
          git config user.email "actions@github.com"

          # Ensure we are on the latest main branch
          git fetch origin main
          git checkout main
          git pull origin main

          # Create and switch to a new branch using variables and new naming convention
          BRANCH_NAME="bump-${{ steps.get_basic_info.outputs.plugin_name }}-plugin-${{ steps.get_basic_info.outputs.version }}"
          git checkout -b "$BRANCH_NAME"

          # Add and commit changes (using git add .)
          git add .
          git status # for debugging
          # Use variables in commit message
          git commit -m "bump ${{ steps.get_basic_info.outputs.plugin_name }} plugin to version ${{ steps.get_basic_info.outputs.version }}"

          # Push to remote (use force just in case the branch existed before from a failed run)
          git push -u origin "$BRANCH_NAME" --force

          # Confirm branch has been pushed and wait for sync (GitHub API might need a moment)
          git branch -a
          echo "Waiting for branch to sync..."
          sleep 10  # Wait 10 seconds for branch sync

      - name: Create PR via GitHub API
        env:
          GH_TOKEN: ${{ secrets.PLUGIN_ACTION }} # Use the provided token for authentication
        run: |
          gh pr create \
            --repo langgenius/dify-plugins \
            --head "${{ steps.get_basic_info.outputs.author }}:${{ steps.get_basic_info.outputs.plugin_name }}-${{ steps.get_basic_info.outputs.version }}" \
            --base main \
            --title "bump ${{ steps.get_basic_info.outputs.plugin_name }} plugin to version ${{ steps.get_basic_info.outputs.version }}" \
            --body "bump ${{ steps.get_basic_info.outputs.plugin_name }} plugin package to version ${{ steps.get_basic_info.outputs.version }}

            Changes:
            - Updated plugin package file" || echo "PR already exists or creation skipped." # Handle cases where PR already exists

      - name: Print environment info # Kept for debugging
        run: |
          echo "GITHUB_WORKSPACE: $GITHUB_WORKSPACE"
          echo "Current directory contents:"
          ls -R
4

Update manifest.yaml

Ensure those following fields are correctly set:

version: 0.0.x  # Version number
author: your-github-username  # GitHub username/Author name
name: your-plugin-name  # Plugin name

Usage Guide

First-time Setup

When setting up the auto-publish workflow for the first time, complete these steps:

  1. Ensure you have forked the official dify-plugins repository

  2. Ensure your plugin source repository structure is correct

  3. Set up the PLUGIN_ACTION Secret in your plugin source repository

  4. Create the workflow file .github/workflows/plugin-publish.yml

  5. Ensure the name and author fields in the manifest.yaml file are correctly configured

Subsequent Update

To publish new versions after setup:

  1. Modify the code

  2. Update the version field in manifest.yaml

  1. Push all changes to the main branch

  2. Wait for GitHub Actions to complete packaging, branch creation, and PR submission

Outcome

When you push code to the main branch of your plugin source repository, GitHub Actions will automatically execute the publishing process:

  • Package the plugin in {plugin-name}-{version}.difypkg format

  • Push the packaged file to the target repository

  • Create a PR to merge into the fork repository

Example Repository

Create Secrets
Release
Outcome

See to understand configuration and best practices.

example repository