Skip to content

Commit 1895087

Browse files
authored
Merge pull request #313 from genlayerlabs/chore/nod-561-update-docs-github-workflow
chore: Update docs workflow to sync docker-compose
2 parents ccd959c + 7bdc20e commit 1895087

13 files changed

Lines changed: 349 additions & 176 deletions

File tree

.github/actions/sync-files/action.yml

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ inputs:
2121
description: 'Comma-separated list of filenames to exclude'
2222
required: false
2323
default: 'README,CHANGELOG,.gitignore,.gitkeep'
24-
sanitize_script:
25-
description: 'Optional script path to run after sync (for sanitization/post-processing)'
26-
required: false
27-
default: ''
2824
outputs:
2925
added:
3026
description: 'Number of files added'
@@ -46,42 +42,64 @@ runs:
4642
shell: bash
4743
run: |
4844
# For config type, handle special case:
49-
# 1. Copy config.yaml.example to temp location as config.yaml
50-
# 2. Run sanitization on the renamed file
51-
# 3. Use the sanitized file as source for sync
52-
45+
# Copy config.yaml.example to temp location as config.yaml and sanitize
46+
5347
if [[ -f "${{ inputs.source_path }}" ]]; then
5448
# Create temp directory
5549
TEMP_DIR=$(mktemp -d)
5650
echo "TEMP_CONFIG_DIR=$TEMP_DIR" >> $GITHUB_ENV
57-
51+
5852
# Copy and rename config.yaml.example to config.yaml
5953
cp "${{ inputs.source_path }}" "$TEMP_DIR/config.yaml"
60-
61-
# Run sanitization if script is provided
62-
if [[ -n "${{ inputs.sanitize_script }}" ]] && [[ -f "${{ inputs.sanitize_script }}" ]]; then
63-
echo "Sanitizing config file..."
64-
bash "${{ inputs.sanitize_script }}" "$TEMP_DIR/config.yaml"
65-
fi
66-
54+
55+
# Sanitize: replace RPC URLs with placeholders and remove dev section
56+
bash .github/scripts/sanitize-config.sh "$TEMP_DIR/config.yaml"
57+
6758
# Update source path for sync
6859
echo "CONFIG_SOURCE=$TEMP_DIR/config.yaml" >> $GITHUB_ENV
6960
else
7061
echo "Config source file not found: ${{ inputs.source_path }}"
7162
exit 1
7263
fi
73-
64+
65+
- name: Prepare docker-compose file
66+
if: inputs.type == 'docker_compose'
67+
shell: bash
68+
run: |
69+
# For docker_compose type, handle special case:
70+
# Copy and sanitize (remove alloy service and volumes)
71+
72+
if [[ -f "${{ inputs.source_path }}" ]]; then
73+
# Create temp directory
74+
TEMP_DIR=$(mktemp -d)
75+
echo "TEMP_DOCKER_COMPOSE_DIR=$TEMP_DIR" >> $GITHUB_ENV
76+
77+
# Copy docker-compose.yaml
78+
cp "${{ inputs.source_path }}" "$TEMP_DIR/docker-compose.yaml"
79+
80+
# Sanitize: remove alloy service and volumes section using yq
81+
bash .github/scripts/sanitize-docker-compose.sh "$TEMP_DIR/docker-compose.yaml"
82+
83+
# Update source path for sync
84+
echo "DOCKER_COMPOSE_SOURCE=$TEMP_DIR/docker-compose.yaml" >> $GITHUB_ENV
85+
else
86+
echo "Docker compose source file not found: ${{ inputs.source_path }}"
87+
exit 1
88+
fi
89+
7490
- name: Sync files
7591
id: sync
7692
shell: bash
7793
run: |
78-
# Use prepared config source if it's a config type, otherwise use original source
94+
# Use prepared source for config/docker_compose types, otherwise use original source
7995
if [[ "${{ inputs.type }}" == "config" ]] && [[ -n "$CONFIG_SOURCE" ]]; then
8096
SOURCE_PATH="$CONFIG_SOURCE"
97+
elif [[ "${{ inputs.type }}" == "docker_compose" ]] && [[ -n "$DOCKER_COMPOSE_SOURCE" ]]; then
98+
SOURCE_PATH="$DOCKER_COMPOSE_SOURCE"
8199
else
82100
SOURCE_PATH="${{ inputs.source_path }}"
83101
fi
84-
102+
85103
${{ github.action_path }}/sync.sh \
86104
"${{ inputs.type }}" \
87105
"${{ inputs.title }}" \
@@ -97,7 +115,15 @@ runs:
97115
if [[ -n "$TEMP_CONFIG_DIR" ]] && [[ -d "$TEMP_CONFIG_DIR" ]]; then
98116
rm -rf "$TEMP_CONFIG_DIR"
99117
fi
100-
118+
119+
- name: Cleanup docker-compose temp directory
120+
if: inputs.type == 'docker_compose' && always()
121+
shell: bash
122+
run: |
123+
if [[ -n "$TEMP_DOCKER_COMPOSE_DIR" ]] && [[ -d "$TEMP_DOCKER_COMPOSE_DIR" ]]; then
124+
rm -rf "$TEMP_DOCKER_COMPOSE_DIR"
125+
fi
126+
101127
- name: Upload artifacts
102128
uses: actions/upload-artifact@v4
103129
if: always()

.github/scripts/doc-generator.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,16 @@ run_doc_generation() {
3737
failed=true
3838
fi
3939
echo "::endgroup::"
40-
40+
41+
echo "::group::Running node-update-docker-compose"
42+
if npm run node-update-docker-compose; then
43+
echo "✅ Updated docker-compose in setup guide"
44+
else
45+
echo "❌ node-update-docker-compose failed"
46+
failed=true
47+
fi
48+
echo "::endgroup::"
49+
4150
echo "::group::Running node-generate-api-docs"
4251
if npm run node-generate-api-docs; then
4352
echo "✅ Generated API documentation"

.github/scripts/sanitize-config.py

Lines changed: 0 additions & 119 deletions
This file was deleted.

.github/scripts/sanitize-config.sh

100755100644
Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/bin/bash
22
set -e
33

4-
# Sanitize GenLayer config file for documentation
4+
# Sanitize config.yaml for documentation
5+
# Replaces RPC URLs with placeholders and removes dev section
56
# Usage: sanitize-config.sh <config_file>
67

78
CONFIG_FILE="$1"
@@ -18,17 +19,13 @@ fi
1819

1920
echo "Sanitizing config file: $CONFIG_FILE"
2021

21-
# Replace URLs with TODO placeholders (only on non-commented lines; preserve indent)
22-
sed -i.bak -E '/^[[:space:]]*#/! s|^([[:space:]]*)zksyncurl:[[:space:]]*".*"|\1zksyncurl: "TODO: Set your GenLayer Chain ZKSync HTTP RPC URL here"|' "$CONFIG_FILE"
23-
sed -i.bak -E '/^[[:space:]]*#/! s|^([[:space:]]*)zksyncwebsocketurl:[[:space:]]*".*"|\1zksyncwebsocketurl: "TODO: Set your GenLayer Chain ZKSync WebSocket RPC URL here"|' "$CONFIG_FILE"
24-
rm -f "${CONFIG_FILE}.bak"
22+
# Use yq to:
23+
# 1. Replace RPC URLs with TODO placeholders
24+
# 2. Delete node.dev section
25+
yq -i '
26+
.rollup.genlayerchainrpcurl = "TODO: Set your GenLayer Chain ZKSync HTTP RPC URL here" |
27+
.rollup.genlayerchainwebsocketurl = "TODO: Set your GenLayer Chain ZKSync WebSocket RPC URL here" |
28+
del(.node.dev)
29+
' "$CONFIG_FILE"
2530

26-
# Remove node.dev sections using Python script
27-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
28-
if [[ -f "$SCRIPT_DIR/sanitize-config.py" ]]; then
29-
python3 "$SCRIPT_DIR/sanitize-config.py" "$CONFIG_FILE"
30-
else
31-
echo "Warning: sanitize-config.py not found, skipping Python sanitization"
32-
fi
33-
34-
echo "Config sanitization completed"
31+
echo "Config sanitization completed"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Sanitize docker-compose.yaml for documentation
5+
# Removes the alloy service and volumes section
6+
# Usage: sanitize-docker-compose.sh <docker_compose_file>
7+
8+
DOCKER_COMPOSE_FILE="$1"
9+
10+
if [[ -z "$DOCKER_COMPOSE_FILE" ]]; then
11+
echo "Usage: $0 <docker_compose_file>" >&2
12+
exit 1
13+
fi
14+
15+
if [[ ! -f "$DOCKER_COMPOSE_FILE" ]]; then
16+
echo "File not found: $DOCKER_COMPOSE_FILE" >&2
17+
exit 1
18+
fi
19+
20+
echo "Sanitizing docker-compose file: $DOCKER_COMPOSE_FILE"
21+
22+
# Use yq to remove alloy service and volumes section
23+
yq -i 'del(.services.alloy) | del(.volumes)' "$DOCKER_COMPOSE_FILE"
24+
25+
# Remove leftover comments about alloy (yq preserves them)
26+
sed -i '/# Grafana Alloy/,/^[^ #]/{ /^[^ #]/!d }' "$DOCKER_COMPOSE_FILE"
27+
sed -i '/^$/N;/^\n$/d' "$DOCKER_COMPOSE_FILE"
28+
29+
echo "Docker-compose sanitization completed"

.github/workflows/README.md

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ This workflow automatically synchronizes documentation from the `genlayerlabs/ge
1212
### What it does
1313

1414
1. **Prepare**: Detects version from input or automatically finds latest tag
15-
2. **Sync Files** (parallel matrix strategy, 5 sync types):
15+
2. **Sync Files** (parallel matrix strategy, 6 sync types):
1616
- **Changelog files**`content/validators/changelog/`
17-
- **Config file**`content/validators/config.yaml` (with sanitization)
17+
- **Config file**`content/validators/config.yaml`
18+
- **Docker Compose file**`content/validators/docker-compose.yaml`
1819
- **API gen method docs**`pages/api-references/genlayer-node/gen/` (filtered by regex)
1920
- **API debug method docs**`pages/api-references/genlayer-node/debug/` (filtered by regex)
2021
- **API ops method docs**`pages/api-references/genlayer-node/ops/`
@@ -113,6 +114,8 @@ docs/
113114
configs/
114115
└── node/
115116
└── config.yaml.example # Will be copied to content/validators/config.yaml
117+
release/
118+
└── docker-compose.yaml # Will be copied to content/validators/docker-compose.yaml
116119
```
117120
118121
### Customizing Paths and Filtering
@@ -141,7 +144,7 @@ The workflow uses 7 main jobs with the following dependency chain:
141144
```
142145
prepare (version detection)
143146
144-
sync-files (matrix: 5 parallel jobs)
147+
sync-files (matrix: 6 parallel jobs)
145148
146149
aggregate-results (merges artifacts)
147150
@@ -167,16 +170,21 @@ The workflow uses composite actions for code reusability:
167170
- `.github/scripts/sync-artifact-files.sh` - Applies synced files to repository with rsync --delete
168171
- `.github/scripts/aggregate-reports.sh` - Aggregates sync metrics from parallel jobs
169172
- `.github/scripts/git-utils.sh` - Branch creation, commit, and push operations
170-
- `.github/scripts/sanitize-config.sh` - Sanitizes config files (URLs and dev sections)
171-
- `.github/scripts/sanitize-config.py` - Python script to remove node.dev sections
172173
- `.github/scripts/version-utils.sh` - Version detection and validation
173174
- `.github/scripts/doc-generator.sh` - Wrapper for npm documentation generation
175+
- `.github/scripts/sanitize-config.sh` - Sanitizes config file (replaces URLs, removes dev section)
176+
- `.github/scripts/sanitize-docker-compose.sh` - Removes alloy service and volumes from docker-compose
174177
175-
### Config File Sanitization
176-
The config sync process includes automatic sanitization:
177-
1. **URL Replacement**: Real URLs replaced with TODO placeholders
178-
2. **Dev Section Removal**: `node.dev` sections stripped using Python script
179-
3. **Comparison**: Only sanitized content is compared to detect actual changes
178+
### Config Sanitization
179+
The config sync process includes automatic sanitization using `yq`:
180+
- **URL Replacement**: RPC URLs replaced with TODO placeholders
181+
- **Dev Section Removal**: `node.dev` section is removed
182+
183+
### Docker Compose Sanitization
184+
The docker-compose sync process includes automatic sanitization using `yq` and `sed`:
185+
- **Alloy Service Removal**: The `alloy` monitoring service is removed
186+
- **Volumes Removal**: The `volumes` section is removed
187+
- **Comment Cleanup**: Alloy-related comments are removed
180188
181189
### Branch Naming Convention
182190
Sync branches follow the pattern: `docs/node/{version}`
@@ -228,5 +236,6 @@ The summary job generates a comprehensive report in the GitHub Actions UI:
228236
After syncing files, the workflow runs these npm scripts:
229237
- `npm run node-generate-changelog` - Generates changelog page from synced files
230238
- `npm run node-update-setup-guide` - Updates setup guide with version info
231-
- `npm run node-update-config` - Processes configuration documentation
239+
- `npm run node-update-config` - Updates config.yaml example in setup guide
240+
- `npm run node-update-docker-compose` - Updates docker-compose.yaml example in setup guide
232241
- `npm run node-generate-api-docs` - Generates API reference pages

0 commit comments

Comments
 (0)