Update 17_186_mcp_cli_testing.html #282
Workflow file for this run
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: Validate and Sync Content | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request_target: | |
| types: [ labeled, synchronize, opened ] | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref_name }} | |
| cancel-in-progress: false | |
| jobs: | |
| validate: | |
| name: Validate HTML Content | |
| runs-on: arc-runners-small | |
| steps: | |
| - name: Checkout base branch for pull_request_target | |
| if: github.event_name == 'pull_request_target' | |
| uses: actions/checkout@v5 | |
| with: | |
| ref: ${{ github.event.pull_request.base.ref }} | |
| - name: Checkout current ref for push and workflow_dispatch | |
| if: github.event_name != 'pull_request_target' | |
| uses: actions/checkout@v5 | |
| - name: Configure git identity | |
| if: github.event_name == 'pull_request_target' | |
| run: | | |
| git config user.name "github-actions" | |
| git config user.email "github-actions@github.com" | |
| - name: Fetch head branch for pull_request_target | |
| if: github.event_name == 'pull_request_target' | |
| run: git fetch https://github.com/${{ github.event.pull_request.head.repo.full_name }} ${{ github.event.pull_request.head.ref }} | |
| - name: Merge head into base for pull_request_target | |
| if: github.event_name == 'pull_request_target' | |
| run: | | |
| git merge --no-ff FETCH_HEAD || (echo "Merge conflict detected" && exit 1) | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: "22" | |
| - name: Install dependencies (Node) | |
| # Assuming package.json is at the root and contains necessary deps for validation script | |
| run: npm install | |
| - name: Validate HTML content | |
| run: node .github/scripts/validate-content.js | |
| - name: Post comment | |
| if: | | |
| (failure() || success()) && github.event_name == 'pull_request_target' | |
| uses: mshick/add-pr-comment@v2 | |
| with: | |
| refresh-message-position: true | |
| message-id: validation | |
| message: failure | |
| message-success: | | |
| ## Validation Success | |
| message-failure: | | |
| ## Validation is failed | |
| Please check [run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) | |
| sync-templates: | |
| name: Sync Templates to Supabase | |
| if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' | |
| runs-on: arc-runners-small | |
| needs: validate # Depends on the 'validate' job succeeding | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.10" | |
| - name: Install dependencies (Python) | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install supabase | |
| - name: Sync templates to Supabase | |
| env: | |
| SUPABASE_URL: ${{ secrets.SUPABASE_URL }} | |
| SUPABASE_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }} | |
| run: python .github/scripts/sync_templates.py | |
| sync-content: | |
| name: Sync Stage Content to Supabase | |
| if: github.event_name != 'pull_request_target' || contains(github.event.pull_request.labels.*.name, 'safe-to-run') | |
| runs-on: arc-runners-small | |
| needs: validate # Depends on the 'validate' job succeeding | |
| steps: | |
| - name: Checkout base branch for pull_request_target | |
| if: github.event_name == 'pull_request_target' | |
| uses: actions/checkout@v5 | |
| with: | |
| ref: ${{ github.event.pull_request.base.ref }} | |
| fetch-depth: 0 | |
| - name: Checkout current ref for push and workflow_dispatch | |
| if: github.event_name != 'pull_request_target' | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Configure git identity | |
| if: github.event_name == 'pull_request_target' | |
| run: | | |
| git config user.name "github-actions" | |
| git config user.email "github-actions@github.com" | |
| - name: Fetch head branch for pull_request_target | |
| if: github.event_name == 'pull_request_target' | |
| run: git fetch https://github.com/${{ github.event.pull_request.head.repo.full_name }} ${{ github.event.pull_request.head.ref }} | |
| - name: Merge head into base for pull_request_target | |
| if: github.event_name == 'pull_request_target' | |
| run: | | |
| git merge --no-ff FETCH_HEAD || (echo "Merge conflict detected" && exit 1) | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.10" | |
| - name: Install dependencies (Python) | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install supabase | |
| - name: Sync stage content to Supabase | |
| id: sync-content | |
| env: | |
| SUPABASE_URL: ${{ secrets.SUPABASE_URL }} | |
| SUPABASE_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }} | |
| PR_NUMBER: ${{ github.event.number }} | |
| run: | | |
| python .github/scripts/sync_content.py | tee sync_output.log | |
| # Extract draft project information from the output | |
| if grep -q "DRAFT_PROJECT:" sync_output.log; then | |
| echo "draft_projects_found=true" >> $GITHUB_OUTPUT | |
| grep "DRAFT_PROJECT:" sync_output.log > draft_projects.txt | |
| else | |
| echo "draft_projects_found=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Generate comment body with draft project links | |
| if: ${{ github.event_name == 'pull_request_target' && steps.sync-content.outputs.draft_projects_found == 'true' }} | |
| id: generate-comment | |
| run: | | |
| # Read draft projects data | |
| COMMENT_BODY="" | |
| while IFS= read -r line; do | |
| if [[ $line == DRAFT_PROJECT:* ]]; then | |
| # Parse the line: DRAFT_PROJECT:<draft_id>:<original_id>:<title> | |
| IFS=':' read -r _ DRAFT_ID ORIGINAL_ID TITLE_REST <<< "$line" | |
| # Handle titles that might contain colons | |
| TITLE="${line#DRAFT_PROJECT:$DRAFT_ID:$ORIGINAL_ID:}" | |
| # Add project to comment body | |
| COMMENT_BODY+="- [${TITLE}](https://enlightby.ai/projects/${DRAFT_ID}) (Draft ID: ${DRAFT_ID}, Original ID: ${ORIGINAL_ID})" | |
| fi | |
| done < draft_projects.txt | |
| # Escape newlines for GitHub Actions output | |
| COMMENT_BODY="${COMMENT_BODY//'%'/'%25'}" | |
| COMMENT_BODY="${COMMENT_BODY//$'\n'/'%0A'}" | |
| COMMENT_BODY="${COMMENT_BODY//$'\r'/'%0D'}" | |
| echo "comment_body=${COMMENT_BODY}" >> $GITHUB_OUTPUT | |
| - name: Post comment with draft project links | |
| if: ${{ github.event_name == 'pull_request_target' && steps.sync-content.outputs.draft_projects_found == 'true' }} | |
| uses: mshick/add-pr-comment@v2 | |
| with: | |
| refresh-message-position: true | |
| message-id: draft | |
| status: success | |
| message-success: | | |
| ## 🚀 Draft Projects Created | |
| The following draft projects have been created in this PR: | |
| ${{ steps.generate-comment.outputs.comment_body }} |