Skip to content

Commit 07f30eb

Browse files
authored
Create main.yml
1 parent 1bf042b commit 07f30eb

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

.github/workflows/main.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Update Documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'README.md'
9+
10+
jobs:
11+
update-docs:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v3
17+
18+
- name: Set up Git
19+
run: |
20+
git config --global user.name 'naderzare'
21+
git config --global user.email 'nader.zare88@gmail.com'
22+
23+
- name: Check if README was updated
24+
run: |
25+
if git diff --name-only HEAD^ HEAD | grep 'README.md'; then
26+
echo "README.md has changed"
27+
else
28+
echo "README.md has not changed" && exit 0
29+
fi
30+
31+
- name: Generate random number for branch name
32+
id: random
33+
run: echo "::set-output name=random_number::$(shuf -i 1000-9999 -n 1)"
34+
35+
- name: Clone the second repository
36+
run: |
37+
git clone https://github.com/CLSFramework/CLSFramework.github.io.git
38+
cd CLSFramework.github.io
39+
40+
# Copy updated README to target directory
41+
cp ../README.md docs/2-sampleserver/0-sample-python-base-code-gRPC/index.md
42+
43+
# Create a new branch with random number appended
44+
git checkout -b update-readme-grpc-${{ steps.random.outputs.random_number }}
45+
46+
# Commit the changes
47+
git add docs/2-sampleserver/0-sample-python-base-code-gRPC/index.md
48+
git commit -m "Update sample server documentation from README"
49+
50+
# Push the new branch
51+
git push origin update-readme-grpc-${{ steps.random.outputs.random_number }}
52+
53+
- name: Create Pull Request
54+
uses: peter-evans/create-pull-request@v5
55+
with:
56+
token: ${{ secrets.GITHUB_TOKEN }}
57+
branch: update-readme-grpc-${{ steps.random.outputs.random_number }}
58+
commit-message: "Update sample server documentation from README"
59+
title: "Update sample server documentation"
60+
body: "This PR updates the sample server documentation based on changes made in README.md."
61+
base: main

0 commit comments

Comments
 (0)