Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions .github/workflows/push_on_public_repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: Push documentation on target repository
on:
workflow_dispatch:
inputs:
base_branch:
description: 'Private repository branch from which to checkout'
source_branch:
description: 'Source repository branch from which to checkout'
required: true
default: 'docs/from-gitbook'
type: string
Expand Down Expand Up @@ -38,11 +38,11 @@ jobs:
push-to-target:
runs-on: ubuntu-latest
steps:
- name: Checkout private repository
uses: actions/checkout@v4
- name: Checkout source repository
uses: actions/checkout@v6
with:
ref: ${{ inputs.base_branch }}
path: private_repo
ref: ${{ inputs.source_branch }}
path: source_repo

- name: Checkout target repository
uses: actions/checkout@v6
Expand All @@ -52,13 +52,20 @@ jobs:
token: ${{ secrets.PAT }}
path: target_repo

- name: Sync Repositories content
- name: Sync Repositories content (Incremental)
if: ${{ inputs.paths_to_add != '' || inputs.paths_to_remove != '' }}
env:
PATHS_TO_ADD: ${{ inputs.paths_to_add }}
PATHS_TO_REMOVE: ${{ inputs.paths_to_remove }}
run: |
chmod +x private_repo/scripts/sync_repo.sh
./private_repo/scripts/sync_repo.sh
chmod +x source_repo/scripts/sync_repo.sh
./source_repo/scripts/sync_repo.sh

- name: Sync Repositories content (Full)
if: ${{ inputs.paths_to_add == '' && inputs.paths_to_remove == '' }}
run: |
chmod +x source_repo/scripts/sync_full_repo.sh
./source_repo/scripts/sync_full_repo.sh

- name: Push commit to target repo
env:
Expand Down
10 changes: 5 additions & 5 deletions scripts/sync_repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ for path in "${add_array[@]}"; do
rm -rf "target_repo/$target_path"
fi

if [[ -e "private_repo/$path" ]]; then
echo " Found in private_repo. Copying..."
if [[ -e "source_repo/$path" ]]; then
echo " Found in source_repo. Copying..."
mkdir -p "target_repo/$(dirname "$target_path")"
cp -r "private_repo/$path" "target_repo/$target_path"
cp -r "source_repo/$path" "target_repo/$target_path"
else
echo " Warning: Path '$path' does not exist in private_repo."
echo " Warning: Path '$path' does not exist in source_repo."
fi
done

Expand Down Expand Up @@ -87,4 +87,4 @@ for path in "${remove_array[@]}"; do
done

echo ""
echo "=== Operation Completed ==="
echo "=== Operation Completed ==="
24 changes: 24 additions & 0 deletions scripts/synch_full_repo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
set -e

JSON_URL="https://static-contents.developer.pagopa.it/it/dirNames.json"

echo "Downloading path list from $JSON_URL..."
PATHS=$(curl -s "$JSON_URL" | grep -o '"[^"]*"' | grep -v '"dirNames"' | tr -d '"')

echo "Syncing directories..."
for PATH_NAME in $PATHS; do
SRC="./source_repo/docs/$PATH_NAME"
DEST="./public_repo/$PATH_NAME"

if [ -d "$SRC" ]; then
rm -rf "$DEST"
cp -r "$SRC" "$DEST"
echo "Synced: $PATH_NAME"
else
echo "Warning: $SRC does not exist. Skipping..."
fi
done

echo ""
echo "=== Operation Completed ==="