V0.0.6 #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Plugin Publish Workflow | |
| on: | |
| release: | |
| types: [published] | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Download CLI tool | |
| run: | | |
| mkdir -p $RUNNER_TEMP/bin | |
| cd $RUNNER_TEMP/bin | |
| wget https://github.com/langgenius/dify-plugin-daemon/releases/download/0.2.0/dify-plugin-linux-amd64 | |
| chmod +x dify-plugin-linux-amd64 | |
| echo "CLI tool location:" | |
| pwd | |
| ls -la dify-plugin-linux-amd64 | |
| - name: Get basic info from manifest | |
| 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: | | |
| cd $GITHUB_WORKSPACE | |
| PACKAGE_NAME="${{ steps.get_basic_info.outputs.plugin_name }}-${{ steps.get_basic_info.outputs.version }}.difypkg" | |
| $RUNNER_TEMP/bin/dify-plugin-linux-amd64 plugin package . -o "$PACKAGE_NAME" | |
| echo "Package result:" | |
| ls -la "$PACKAGE_NAME" | |
| echo "package_name=$PACKAGE_NAME" >> $GITHUB_OUTPUT | |
| 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: novitalabs/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: | | |
| PACKAGE_NAME="${{ steps.get_basic_info.outputs.plugin_name }}-${{ steps.get_basic_info.outputs.version }}.difypkg" | |
| 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 }}/ | |
| cd dify-plugins | |
| git config user.name "GitHub Actions" | |
| git config user.email "[email protected]" | |
| git fetch origin main | |
| git checkout main | |
| git pull origin main | |
| BRANCH_NAME="bump-${{ steps.get_basic_info.outputs.plugin_name }}-plugin-${{ steps.get_basic_info.outputs.version }}" | |
| git checkout -b "$BRANCH_NAME" | |
| git add . | |
| git commit -m "bump ${{ steps.get_basic_info.outputs.plugin_name }} plugin to version ${{ steps.get_basic_info.outputs.version }}" | |
| git push -u origin "$BRANCH_NAME" --force | |
| git branch -a | |
| echo "Waiting for branch to sync..." | |
| sleep 10 # Wait 10 seconds for branch sync | |
| # Verify branch exists on remote | |
| BRANCH_NAME="bump-${{ steps.get_basic_info.outputs.plugin_name }}-plugin-${{ steps.get_basic_info.outputs.version }}" | |
| git ls-remote --heads origin "$BRANCH_NAME" || { | |
| echo "Branch $BRANCH_NAME not found on remote" | |
| exit 1 | |
| } | |
| - name: Create PR via GitHub API | |
| env: | |
| GH_TOKEN: ${{ secrets.PLUGIN_ACTION }} | |
| run: | | |
| gh auth status | |
| gh pr create \ | |
| --repo langgenius/dify-plugins \ | |
| --head "novitalabs:bump-${{ steps.get_basic_info.outputs.plugin_name }}-plugin-${{ 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 |