Merge PR #2039 #105
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Sync Docs to GitLab | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'docs/**' | |
| - '.github/workflows/sync-docs.yml' | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup SSH for GitLab | |
| run: | | |
| mkdir -p ~/.ssh | |
| echo "${{ secrets.GITLAB_SSH_KEY }}" > ~/.ssh/id_ed25519 | |
| chmod 600 ~/.ssh/id_ed25519 | |
| ssh-keyscan -t ed25519 gitlab.com >> ~/.ssh/known_hosts | |
| - name: Sync docs/ to GitLab | |
| run: | | |
| WORK=$(mktemp -d) | |
| git clone git@gitlab.com:quant-flow/pilot-docs.git "$WORK" | |
| # Preserve GitLab-only infrastructure files (Dockerfile may have | |
| # GitLab-specific changes like apk add nodejs) | |
| BACKUP=$(mktemp -d) | |
| [ -d "$WORK/docker" ] && cp -a "$WORK/docker" "$BACKUP/docker" | |
| # Remove old content (except .git), copy fresh docs | |
| find "$WORK" -mindepth 1 -maxdepth 1 ! -name '.git' -exec rm -rf {} + | |
| cp -a docs/. "$WORK"/ | |
| # Remove dirs that should never be synced to GitLab | |
| rm -rf "$WORK/.next" "$WORK/node_modules" "$WORK/.idea" "$WORK/~" | |
| # Restore GitLab-only infrastructure files | |
| [ -d "$BACKUP/docker" ] && rm -rf "$WORK/docker" && cp -a "$BACKUP/docker" "$WORK/docker" | |
| cd "$WORK" | |
| git config user.name "Pilot CI" | |
| git config user.email "ci@quantflow.studio" | |
| git add -A | |
| # Push content if there are changes | |
| if git diff --cached --quiet; then | |
| echo "No changes to sync" | |
| else | |
| git commit -m "sync: docs from pilot@${GITHUB_SHA::7}" | |
| git push origin main | |
| fi | |
| # Always trigger GitLab deploy via unique prod tag | |
| # GitLab ignores re-pushed tags, so each deploy needs a unique tag name | |
| VERSION=$(git -C "$GITHUB_WORKSPACE" describe --tags --abbrev=0 2>/dev/null | sed 's/^v//') | |
| if [ -n "$VERSION" ]; then | |
| BUILD_NUM=$(date +%Y%m%d%H%M%S) | |
| DEPLOY_TAG="prod-${VERSION}-${BUILD_NUM}" | |
| git tag "$DEPLOY_TAG" | |
| git push origin "$DEPLOY_TAG" | |
| echo "Tagged ${DEPLOY_TAG} to trigger deploy" | |
| fi |