Sync Docs #29
This file contains 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: Sync Docs | |
on: | |
schedule: | |
- cron: '0 */4 * * *' | |
workflow_dispatch: | |
jobs: | |
sync: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the RAGFlow repository | |
# https://github.com/actions/checkout/blob/v3/README.md | |
uses: actions/checkout@v3 | |
with: | |
repository: infiniflow/ragflow | |
# Relative path under $GITHUB_WORKSPACE to place the repository | |
path: source | |
- name: Checkout RAGFlow docs repo | |
uses: actions/checkout@v3 | |
with: | |
repository: infiniflow/ragflow-docs | |
path: target | |
- name: Install Dependences | |
# Install lightweight command-line JSON processor | |
run: sudo apt-get install -y jq | |
- name: Set Env | |
run: | | |
echo "RAGFLOW_MAIN=${GITHUB_WORKSPACE}/source" >> $GITHUB_ENV | |
echo "RAGFLOW_WEBSITE=${GITHUB_WORKSPACE}/target" >> $GITHUB_ENV | |
- name: Export Env | |
run: | | |
export RAGFLOW_MAIN=${{ env.RAGFLOW_MAIN }} | |
export RAGFLOW_WEBSITE=${{ env.RAGFLOW_WEBSITE }} | |
- name: Sync and stage changes | |
run: | | |
cd $RAGFLOW_MAIN && git fetch --tags | |
cd $RAGFLOW_WEBSITE/website && ./sync_docs.sh | |
- name: Create a Pull Request | |
id: create-pr | |
# https://github.com/peter-evans/create-pull-request | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
token: ${{ secrets.FLOW_PAT }} | |
path: target | |
commit-message: Synchronize documentation. | |
committer: Infinity Curator <[email protected]> | |
author: Infinity Curator <[email protected]> | |
signoff: false | |
base: main | |
branch: sync-documentation | |
delete-branch: true | |
draft: false | |
title: '[Cron] Sync and update documentation' | |
body: 'Auto-generated and will be automatically merged.' | |
labels: | | |
automation | |
- name: Check outputs | |
run: | | |
echo "Pull Request Number - ${{ steps.create-pr.outputs.pull-request-number }}" | |
echo "Pull Request Operation - ${{ steps.create-pr.outputs.pull-request-operation }}" | |
- name: Enable auto-merge on the pull request | |
if: steps.create-pr.outputs.pull-request-operation == 'created' | |
uses: peter-evans/enable-pull-request-automerge@v1 | |
with: | |
token: ${{ secrets.FLOW_PAT }} | |
pull-request-number: ${{ steps.create-pr.outputs.pull-request-number }} | |
merge-method: squash | |
- name: Auto approve the pull request | |
if: steps.create-pr.outputs.pull-request-operation == 'created' | |
uses: juliangruber/[email protected] | |
with: | |
# Use Action Bot to approve the pull request because one cannot approve his own. | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
number: ${{ steps.create-pr.outputs.pull-request-number }} |