Skip to content

Remote Docs Sync

Remote Docs Sync #220

# This workflow tries to pull docs changes from given repo
name: Remote Docs Sync
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
module:
required: true
description: 'module name'
git_https:
required: true
description: 'value for https to git repo'
doc_folder:
required: true
description: 'folder to copy over'
default: 'docs'
ref_name:
required: true
description: 'the branch or tag to copy from'
ref_type:
required: true
description: 'the type of ref. Valid values are branch or tag'
repository_dispatch:
jobs:
sync-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout caraml-dev/docs repo
uses: actions/checkout@v3
with:
ref: main
- name: Sync changes from ${{ github.event.inputs.module }} repos
run: |
if [ -d "module/${{ github.event.inputs.module }}" ]
then
git rm -rf module/${{ github.event.inputs.module }}
fi
if [ ${{ github.event.inputs.ref_type }} = 'branch' ]; then
git remote add -f -t ${{ github.event.inputs.ref_name }} --no-tags ${{ github.event.inputs.module }} ${{ github.event.inputs.git_https }}
git read-tree --prefix=module/${{ github.event.inputs.module }} -u ${{ github.event.inputs.module }}/${{ github.event.inputs.ref_name }}:${{ github.event.inputs.doc_folder }}
elif [ ${{ github.event.inputs.ref_type }} = 'tag' ]; then
git remote add -f -t main --tags ${{ github.event.inputs.module }} ${{ github.event.inputs.git_https }}
git read-tree --prefix=module/${{ github.event.inputs.module }} -u tags/${{ github.event.inputs.ref_name }}:${{ github.event.inputs.doc_folder }}
fi
if [ -n "$(git status --porcelain)" ]; then
git config user.name github-actions
git config user.email [email protected]
git add .
git commit -m "sync ${{ github.event.inputs.module }} docs: $(date +'%Y-%m-%dT%H:%M:%S')Z"
git push
else
echo "Nothing to commit"
fi