-
Notifications
You must be signed in to change notification settings - Fork 2
58 lines (53 loc) · 2.21 KB
/
remote_docs_sync.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# 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