Skip to content

Commit 3bd9b9f

Browse files
authored
Merge pull request #257 from genlayerlabs/chore/nod-189-ci-automate-changelog
chore(workflows): Simplify sync-docs-from-node workflow
2 parents e21ec24 + 1e91472 commit 3bd9b9f

4 files changed

Lines changed: 396 additions & 108 deletions

File tree

‎.github/scripts/sanitize-config.py‎

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,39 @@
77
"""
88

99
import sys
10-
import yaml
10+
import re
1111

1212

1313
def sanitize_config(config_file_path):
14-
"""Remove node.dev and node.admin sections from config file."""
14+
"""Remove node.dev and node.admin sections from config file using regex."""
15+
print(f"Sanitizing config file: {config_file_path}")
16+
1517
# Read the YAML file
1618
with open(config_file_path, 'r') as f:
17-
config = yaml.safe_load(f)
19+
content = f.read()
20+
21+
print(f"Original file size: {len(content)} bytes")
1822

19-
# Remove node.dev and node.admin if they exist
20-
if 'node' in config:
21-
if 'dev' in config['node']:
22-
del config['node']['dev']
23-
if 'admin' in config['node']:
24-
del config['node']['admin']
23+
# Remove node.admin section
24+
# This regex matches the admin: line and all indented content that follows
25+
admin_pattern = r'(\n\s+admin:\s*\n(?:\s+(?:port:\s*\d+|\S.*)\s*\n)*)'
26+
if re.search(admin_pattern, content):
27+
content = re.sub(admin_pattern, '\n', content)
28+
print("Removed node.admin section")
2529

26-
# Write back to file preserving the structure
30+
# Remove node.dev section
31+
# This regex matches the dev: line and all indented content that follows
32+
dev_pattern = r'(\n\s+dev:\s*\n(?:\s+\S.*\s*\n)*)'
33+
if re.search(dev_pattern, content):
34+
content = re.sub(dev_pattern, '\n', content)
35+
print("Removed node.dev section")
36+
37+
# Write back to file
2738
with open(config_file_path, 'w') as f:
28-
yaml.dump(config, f, default_flow_style=False, sort_keys=False, allow_unicode=True)
39+
f.write(content)
40+
41+
print(f"Sanitized file size: {len(content)} bytes")
42+
print("Config sanitization completed")
2943

3044

3145
def main():

‎.github/workflows/README.md‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ Add this to a workflow in the genlayer-node repository:
4545
{
4646
"source_branch": "${{ github.ref_name }}",
4747
"changelog_path": "docs/changelog",
48-
"api_gen_path": "docs/api/rpc/gen",
49-
"api_debug_path": "docs/api/rpc/debug",
48+
"api_gen_path": "docs/api/rpc",
49+
"api_debug_path": "docs/api/rpc",
5050
"api_gen_regex": "gen_(?!dbg_).*",
5151
"api_debug_regex": "gen_dbg_.*"
5252
}
@@ -81,8 +81,8 @@ From the Actions tab:
8181
3. Specify parameters:
8282
- Tag for branch naming (required, e.g., v0.3.5)
8383
- Source branch (optional, default: main)
84-
- API gen path (optional, default: `docs/api/rpc/gen`)
85-
- API debug path (optional, default: `docs/api/rpc/debug`)
84+
- API gen path (optional, default: `docs/api/rpc`)
85+
- API debug path (optional, default: `docs/api/rpc`)
8686
- API gen regex filter (optional, default: `gen_(?!dbg_).*`)
8787
- API debug regex filter (optional, default: `gen_dbg_.*`)
8888

@@ -114,8 +114,8 @@ The source paths and filters can be customized in the event payload:
114114
115115
#### Paths
116116
- `changelog_path`: Path to changelog files (default: `docs/changelog`)
117-
- `api_gen_path`: Path to API gen methods (default: `docs/api/rpc/gen`)
118-
- `api_debug_path`: Path to API debug methods (default: `docs/api/rpc/debug`)
117+
- `api_gen_path`: Path to API gen methods (default: `docs/api/rpc`)
118+
- `api_debug_path`: Path to API debug methods (default: `docs/api/rpc`)
119119
120120
#### Regex Filters
121121
- `api_gen_regex`: Regex pattern to filter gen API files (default: `gen_(?!dbg_).*`)

‎.github/workflows/example-trigger-from-node.yml.example‎

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ jobs:
2222
with:
2323
fetch-depth: 0 # Fetch all history for tags
2424

25-
- name: Get latest tag
26-
id: get_tag
25+
- name: Get version
26+
id: get_version
2727
run: |
28-
# Get the latest tag
29-
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
30-
if [ -z "$LATEST_TAG" ]; then
28+
# Get the latest tag as the version
29+
VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
30+
if [ -z "$VERSION" ]; then
3131
# Fallback to commit SHA if no tags found
32-
LATEST_TAG="commit-$(git rev-parse --short HEAD)"
32+
VERSION="commit-$(git rev-parse --short HEAD)"
3333
fi
34-
echo "tag=$LATEST_TAG" >> $GITHUB_OUTPUT
34+
echo "version=$VERSION" >> $GITHUB_OUTPUT
3535

3636
- name: Trigger documentation sync
3737
uses: peter-evans/repository-dispatch@v2
@@ -43,11 +43,10 @@ jobs:
4343
event-type: sync-docs
4444
client-payload: |
4545
{
46-
"source_branch": "${{ github.ref_name }}",
47-
"tag": "${{ steps.get_tag.outputs.tag }}",
46+
"version": "${{ steps.get_version.outputs.version }}",
4847
"changelog_path": "docs/changelog",
49-
"api_gen_path": "docs/api/rpc/gen",
50-
"api_debug_path": "docs/api/rpc/debug",
48+
"api_gen_path": "docs/api/rpc",
49+
"api_debug_path": "docs/api/rpc",
5150
"api_gen_regex": "gen_(?!dbg_).*",
5251
"api_debug_regex": "gen_dbg_.*"
5352
}
@@ -56,5 +55,4 @@ jobs:
5655
run: |
5756
echo "✅ Triggered documentation sync" >> $GITHUB_STEP_SUMMARY
5857
echo "- Target repository: genlayerlabs/genlayer-docs" >> $GITHUB_STEP_SUMMARY
59-
echo "- Source branch: ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
60-
echo "- Tag: ${{ steps.get_tag.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
58+
echo "- Version: ${{ steps.get_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)