Skip to content

Commit 287e920

Browse files
authored
Add sync and distill workflow (#6)
* add workflow and example json Signed-off-by: maxwolfs <[email protected]> * remove debug step Signed-off-by: maxwolfs <[email protected]> * remove unnecessary lines Signed-off-by: maxwolfs <[email protected]> * fix Signed-off-by: maxwolfs <[email protected]> Signed-off-by: maxwolfs <[email protected]>
1 parent 57fdecd commit 287e920

File tree

3 files changed

+84
-2
lines changed

3 files changed

+84
-2
lines changed
+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
name: Synchronize SCS Docs
3+
4+
"on":
5+
push:
6+
paths:
7+
# only trigger the workflow when docs.json has been changed
8+
- 'docs.json'
9+
branches:
10+
- main
11+
12+
jobs:
13+
provide_repos_json:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
matrix: ${{ steps.set-matrix.outputs.matrix }}
17+
steps:
18+
- name: Checkout the docusaurus repo (B)
19+
uses: actions/checkout@v3
20+
21+
- name: Set Matrix
22+
id: set-matrix
23+
run: |
24+
REPOS=$(echo $(cat ././docs.json) | sed 's/ //g' )
25+
echo "::set-output name=matrix::$REPOS"
26+
27+
sync_repos:
28+
needs: provide_repos_json
29+
runs-on: ubuntu-latest
30+
strategy:
31+
matrix:
32+
repos: ${{ fromJson(needs.provide_repos_json.outputs.matrix) }}
33+
steps:
34+
- name: checkout the docusaurus repo (B)
35+
uses: actions/checkout@v3
36+
37+
- name: clone repo A which is about to be synchronized
38+
uses: sudosubin/[email protected]
39+
with:
40+
repository: ${{matrix.repos.org}}/${{matrix.repos.name}}
41+
path: 'repo_to_be_edited'
42+
43+
- name: remove git folders from A
44+
run: |
45+
rm -rf $(pwd)/repo_to_be_edited/.git
46+
47+
- name: remove README.md files from A
48+
run: |
49+
find $(pwd)/repo_to_be_edited -name "README.md" | xargs rm -f
50+
51+
- name: create docusaurus subdirectory
52+
run: |
53+
mkdir $(pwd)/docs/${{matrix.repos.name}} || true
54+
55+
- name: copy docs content from A to B
56+
run: |
57+
cp -r $(pwd)/repo_to_be_edited/docs/* $(pwd)/docs/${{matrix.repos.name}}
58+
59+
- name: remove repo A
60+
run: |
61+
rm -rf $(pwd)/repo_to_be_edited/
62+
63+
- name: commit and push B
64+
uses: EndBug/add-and-commit@v9
65+
with:
66+
author_name: 'bot@maxwolfs'
67+
committer_name: Action Bot
68+
commit: --signoff
69+
message: "distill"
70+
push: true
71+
pull: --rebase --autostash
72+
add: "docs"

example.docs.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[
2+
{
3+
"name": "openstack-image-manager",
4+
"org": "osism"
5+
},
6+
{
7+
"name": "testbed",
8+
"org": "osism"
9+
}
10+
]

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)