Skip to content

Commit

Permalink
Fix: fix script, commit and push to branch (#36)
Browse files Browse the repository at this point in the history
* Update sync_script.sh

* git diff

* Update copy-md.yml

* Update copy-md.yml

* Update copy-md.yml
  • Loading branch information
samricotta authored Sep 18, 2023
1 parent 461e72d commit 2d05387
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 26 deletions.
32 changes: 15 additions & 17 deletions .github/workflows/copy-md.yml
Original file line number Diff line number Diff line change
@@ -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: |
Expand All @@ -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
26 changes: 17 additions & 9 deletions sync_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."
Expand Down

0 comments on commit 2d05387

Please sign in to comment.