Skip to content
Merged
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
3 changes: 2 additions & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ rustflags = ["-C", "link-arg=-Wl,-z,max-page-size=16384"]
# CODEX PATCHES - namastexlabs/codex fork integration
# Redirects codex dependencies from crates.io to the GitHub fork
# This allows staying up-to-date without vendoring code locally
# NOTE: This section is ALWAYS active, not managed by dev-core
# ============================================================================
# [patch.crates-io]
[patch.crates-io]
mcp-types = { git = "https://github.com/namastexlabs/codex.git", branch = "main" }
codex-protocol = { git = "https://github.com/namastexlabs/codex.git", branch = "main" }
codex-app-server-protocol = { git = "https://github.com/namastexlabs/codex.git", branch = "main" }
Expand Down
154 changes: 154 additions & 0 deletions .github/workflows/sync-to-forge-core.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
name: Sync to forge-core

# Automatically syncs forge-core/ directory changes to the forge-core repository
# when PRs are merged to dev branch in automagik-forge

on:
pull_request:
types: [closed]
branches: [dev]

# Manual trigger for testing or recovery
workflow_dispatch:
inputs:
pr_number:
description: 'PR number to sync from (optional)'
type: string
force:
description: 'Force sync even if no forge-core changes detected'
type: boolean
default: false

jobs:
sync:
# Only run on merged PRs (not closed without merge)
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest

steps:
- name: Checkout automagik-forge
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT_TOKEN }}

- name: Check for forge-core changes
id: changes
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
if [ "${{ inputs.force }}" = "true" ]; then
echo "Force sync requested"
echo "has_changes=true" >> $GITHUB_OUTPUT
exit 0
fi

# For manual runs without PR, check recent commits
echo "Manual trigger - checking for any forge-core files"
if [ -d "forge-core" ]; then
echo "has_changes=true" >> $GITHUB_OUTPUT
else
echo "has_changes=false" >> $GITHUB_OUTPUT
fi
else
# Get changed files in the merged PR
CHANGED=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep '^forge-core/' || echo "")

if [ -z "$CHANGED" ]; then
echo "No forge-core changes detected"
echo "has_changes=false" >> $GITHUB_OUTPUT
else
echo "Found forge-core changes:"
echo "$CHANGED"
echo "has_changes=true" >> $GITHUB_OUTPUT

# Save file list for later
echo "$CHANGED" > /tmp/changed_files.txt
fi
fi

- name: Checkout forge-core repo
if: steps.changes.outputs.has_changes == 'true'
uses: actions/checkout@v4
with:
repository: namastexlabs/forge-core
token: ${{ secrets.PAT_TOKEN }}
path: forge-core-repo
fetch-depth: 0

- name: Sync changes to forge-core
if: steps.changes.outputs.has_changes == 'true'
id: sync
run: |
cd forge-core-repo
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

# Determine target branch (use dev for now, could match PR branch later)
TARGET_BRANCH="dev"
git checkout "$TARGET_BRANCH" || git checkout -b "$TARGET_BRANCH"
git pull origin "$TARGET_BRANCH" || true

# Copy all files from forge-core/ except .git
# Using rsync for reliable sync with proper handling of deletions
rsync -av --delete --exclude='.git' ../forge-core/ ./

# Check if there are actual changes
if git diff --quiet && git diff --staged --quiet; then
echo "No actual changes to commit (files are identical)"
echo "synced=false" >> $GITHUB_OUTPUT
exit 0
fi

# Get PR info for commit message
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
PR_NUM="${{ inputs.pr_number }}"
PR_TITLE="Manual sync"
PR_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
else
PR_NUM="${{ github.event.pull_request.number }}"
PR_TITLE="${{ github.event.pull_request.title }}"
PR_URL="${{ github.event.pull_request.html_url }}"
fi

# Commit changes
git add -A
git commit -m "sync: automagik-forge PR #${PR_NUM}

${PR_TITLE}

Source: ${PR_URL}"

# Push to forge-core
git push origin "$TARGET_BRANCH"

echo "synced=true" >> $GITHUB_OUTPUT
echo "target_branch=$TARGET_BRANCH" >> $GITHUB_OUTPUT

- name: Trigger forge-core pre-release (if rc label)
if: |
steps.sync.outputs.synced == 'true' &&
github.event_name == 'pull_request' &&
contains(github.event.pull_request.labels.*.name, 'rc')
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.PAT_TOKEN }}
repository: namastexlabs/forge-core
event-type: create-pre-release
client-payload: '{"source_pr": "${{ github.event.pull_request.number }}", "source_repo": "automagik-forge"}'

- name: Create summary
if: steps.changes.outputs.has_changes == 'true'
run: |
echo "## Sync to forge-core" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY

if [ "${{ steps.sync.outputs.synced }}" = "true" ]; then
echo "**Status:** Synced successfully" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Target Branch:** ${{ steps.sync.outputs.target_branch }}" >> $GITHUB_STEP_SUMMARY
if [ "${{ github.event_name }}" != "workflow_dispatch" ]; then
echo "- **Source PR:** #${{ github.event.pull_request.number }}" >> $GITHUB_STEP_SUMMARY
fi
else
echo "**Status:** No changes to sync (files identical)" >> $GITHUB_STEP_SUMMARY
fi
51 changes: 31 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading