Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
c21a4e7f
Commit
c21a4e7f
authored
Jan 21, 2024
by
chenhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add sync how-to files action
parent
a18dde9b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
0 deletions
+55
-0
sync-howto-docs.yml
.github/workflows/sync-howto-docs.yml
+55
-0
No files found.
.github/workflows/sync-howto-docs.yml
0 → 100644
View file @
c21a4e7f
name
:
Sync How-To Markdown Files to Documentation Repo
on
:
push
:
branches
:
-
chore/test-howto-sync
paths
:
-
'
**/howto-*.md'
jobs
:
sync-markdown-files
:
runs-on
:
ubuntu-latest
steps
:
-
name
:
Checkout source repository
uses
:
actions/checkout@v4
with
:
fetch-depth
:
0
-
name
:
Sparse Checkout and Sync Files
env
:
TARGET_REPO
:
'
https://github.com/langgenius/dify-docs.git'
TARGET_BRANCH
:
'
test-howto-sync'
ACCESS_TOKEN
:
${{ secrets.REPO_ACCESS_TOKEN_GU }}
run
:
|
CHANGED_FILES=$(git diff --name-only --diff-filter=AMDR origin/${{ github.event.pull_request.base.ref }} ${{ github.event.pull_request.head.ref }} | grep 'howto-.*\.md' || true)
if [ -z "$CHANGED_FILES" ]; then
echo "No new how-to file changes to sync"
exit 0
fi
# sparse checkout dify-docs repo
git clone --depth 1 --filter=blob:none --sparse $TARGET_REPO dify-docs-sparse
cd dify-docs-sparse
git sparse-checkout set en/tutorials/* zh_CN/tutorials/*
# Sync files to different language directories
for file in $CHANGED_FILES; do
if [[ $file == *"_CN.md" ]]; then
TARGET_DIR="zh_CN/tutorials"
else
TARGET_DIR="en/tutorials"
fi
if [ -f "../$file" ]; then
cp "../$file" "$TARGET_DIR/"
else
git rm "$TARGET_DIR/$(basename $file)" || true
fi
done
git config user.name github-actions
git config user.email github-actions@github.com
git add .
git commit -m "Sync how-to markdown files from PR #${{ github.event.pull_request.number }} on main repo"
git push https://${ACCESS_TOKEN}@${TARGET_REPO#https://} HEAD:${TARGET_BRANCH}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment