diff --git a/.github/workflows/copy-md.yml b/.github/workflows/copy-md.yml index 4c57fc377..1995207c0 100644 --- a/.github/workflows/copy-md.yml +++ b/.github/workflows/copy-md.yml @@ -31,6 +31,8 @@ jobs: run: | chmod +x sync_script.sh ./sync_script.sh + chmod +x tutorials-script.sh + ./tutorials-script.sh - name: Add And Commit uses: EndBug/add-and-commit@v9 @@ -69,3 +71,4 @@ jobs: SLACK_COLOR: danger SLACK_MESSAGE: Copying docs is failing SLACK_FOOTER: "" + diff --git a/tutorials-script.sh b/tutorials-script.sh new file mode 100644 index 000000000..b398a96af --- /dev/null +++ b/tutorials-script.sh @@ -0,0 +1,31 @@ +REMOTE_REPO_URL="https://github.com/cosmos/sdk-tutorials.git" + +WORK_DIR=$(pwd) + +cd $WORK_DIR/sdk-tutorials + +mv "$WORK_DIR/sdk-tutorials/tutorials/nameservice" "$WORK_DIR/sdk-tutorials/tutorials/auction-frontrunning" + +# fetch branch from the remote repository and switch to it +git fetch origin master +git checkout master + +# iterate over directories in $WORK_DIR/docs/tutorials e.g $WORK_DIR/docs/tutorials/vote-extensions/oracle +for dir in $WORK_DIR/docs/tutorials/*/*; do + # take category(last part of the directory path) + category=$(basename "$dir") + + # dont include '_category_.json' file + if [[ "$category" == "_category_.json" ]]; then + continue + fi + + # find category that matches within the sdk-tutorials that match the category name + find $WORK_DIR/sdk-tutorials/tutorials/$category -type d -name "docs" | while read docs_dir; do + if [ -d "$docs_dir" ]; then + mkdir -p "$WORK_DIR/docs/tutorials/vote-extensions/$category" + # copy contents of the "docs" folder + cp -r "$docs_dir"/* "$WORK_DIR/docs/tutorials/vote-extensions/$category" + fi + done +done