|
| 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 | + |
| 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" |
0 commit comments