Skip to content

Commit

Permalink
script to copy tutorials
Browse files Browse the repository at this point in the history
  • Loading branch information
samricotta committed Feb 5, 2024
1 parent 412f913 commit 41b9d60
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/copy-md.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -69,3 +71,4 @@ jobs:
SLACK_COLOR: danger
SLACK_MESSAGE: Copying docs is failing
SLACK_FOOTER: ""

31 changes: 31 additions & 0 deletions tutorials-script.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 41b9d60

Please sign in to comment.