From 2d053877d2fe3ff813346fee4b02305b8ac8821b Mon Sep 17 00:00:00 2001 From: samricotta <37125168+samricotta@users.noreply.github.com> Date: Mon, 18 Sep 2023 13:24:58 +0300 Subject: [PATCH] Fix: fix script, commit and push to branch (#36) * Update sync_script.sh * git diff * Update copy-md.yml * Update copy-md.yml * Update copy-md.yml --- .github/workflows/copy-md.yml | 32 +++++++++++++++----------------- sync_script.sh | 26 +++++++++++++++++--------- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/.github/workflows/copy-md.yml b/.github/workflows/copy-md.yml index ce1729ad7..9c7047cf8 100644 --- a/.github/workflows/copy-md.yml +++ b/.github/workflows/copy-md.yml @@ -1,18 +1,22 @@ -name: Copy MD Files and Create PR +name: Copy MD Files on: workflow_dispatch: schedule: - cron: '0 0,12 * * *' - push: jobs: sync-docs-and-create-pr: runs-on: ubuntu-latest + permissions: + contents: write + steps: - name: Checkout Repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 + with: + ref: sync-docs-branch - name: Checkout Sync-Branch run: | @@ -26,25 +30,19 @@ jobs: - name: Install Dependencies run: | - yarn install --frozen-lockfile + yarn install --frozen-lockfile - name: Run Sync Script run: | - chmod +x sync_script.sh + chmod +x sync_script.sh ./sync_script.sh - - uses: stefanzweifel/git-auto-commit-action@v4 - if: always() + - name: Add And Commit + uses: EndBug/add-and-commit@v9 with: - commit_message: sync documentation changes - - - name: Push Changes - run: git push origin sync-docs-branch + message: 'Updated MD File Changes from cosmos-sdk/docs' - - name: Create Pull Request - uses: peter-evans/create-pull-request@v3 + - name: Push To Sync-Docs-Branch + uses: ad-m/github-push-action@master with: - base: main - branch: sync-docs-branch - title: "Sync Documentation Changes" - body: "Automatically generated by GitHub Actions to sync documentation changes." + branch: sync-docs-branch \ No newline at end of file diff --git a/sync_script.sh b/sync_script.sh index 44d0949b2..a49b90057 100755 --- a/sync_script.sh +++ b/sync_script.sh @@ -15,11 +15,19 @@ git clone "$REMOTE_REPO_URL" cosmos-sdk # Read the versions from a JSON file and remove the 'v' prefix VERSIONS=($(jq -r '.[]' versions.json)) +VERSIONS+=("main") + # Iterate over each version for version in "${VERSIONS[@]}"; do - version="${version#v}" # Remove the 'v' prefix from the version number - branch="release/v$version.x" # Determine the branch name - version_directory="version-$version" # Create a directory name based on the version + echo "$version" + if [ "$version" == "main" ]; then + branch="main" # Set the branch to 'main' + version_directory="" # For 'main', the version directory is empty + else + version="${version#v}" # Remove the 'v' prefix from the version number + branch="release/v$version.x" # Determine the branch name + version_directory="version-$version" # Create a directory name based on the version + fi # Skip the '0.47' branch until docs backported if [ "$branch" = "release/v0.47.x" ]; then @@ -51,12 +59,12 @@ for version in "${VERSIONS[@]}"; do # Change back to the original working directory cd "$WORK_DIR" - if [ "$version" == "main" ]; then - local_md_files=$(find "docs" -name "*.md") # For 'main', the version directory is empty - else - # Find all Markdown files in the local versioned_docs directory - local_md_files=$(find "versioned_docs/$version_directory" -name "*.md") - fi + if [ "$version" == "main" ]; then + local_md_files=$(find "docs" -name "*.md") # For 'main', the version directory is empty + else + # Find all Markdown files in the local versioned_docs directory + local_md_files=$(find "versioned_docs/$version_directory" -name "*.md") + fi if [ "$local_md_files" ]; then echo "There are Markdown files in the directory."