This is an automated email from the ASF dual-hosted git repository. harishgokul01 pushed a commit to branch development in repository https://gitbox.apache.org/repos/asf/incubator-resilientdb.git
commit d55b66e6f0443433e99067b47346ccbdc7b360ec Author: harish876 <[email protected]> AuthorDate: Tue Jan 20 00:49:08 2026 +0000 use jq instead to parse projects config --- .github/deploy-ecosystem-configs.json | 9 +++ .github/deploy-ecosystem-configs.yml | 46 ----------- .github/workflows/deploy-ecosystem.yml | 134 ++++++++------------------------- 3 files changed, 41 insertions(+), 148 deletions(-) diff --git a/.github/deploy-ecosystem-configs.json b/.github/deploy-ecosystem-configs.json new file mode 100644 index 00000000..26fd63f1 --- /dev/null +++ b/.github/deploy-ecosystem-configs.json @@ -0,0 +1,9 @@ +{ + "projects": [ + { + "name": "reslens", + "path": "ecosystem/monitoring/reslens", + "vercel_project_id": "prj_g5KA6QQ36ltVydRW6TUKJhgdgYjT" + } + ] +} diff --git a/.github/deploy-ecosystem-configs.yml b/.github/deploy-ecosystem-configs.yml deleted file mode 100644 index 35ca20a7..00000000 --- a/.github/deploy-ecosystem-configs.yml +++ /dev/null @@ -1,46 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# Configuration for Vercel deployments from ecosystem folder -# Add projects here to enable automatic deployment - -projects: - - name: reslens - path: ecosystem/monitoring/reslens - # Vercel project configuration (optional) - # If vercel_project_id is specified, uses existing project - # If not specified, Vercel will create a new project on first deploy - # vercel_org_id: your-org-id # Optional: defaults to VERCEL_ORG_ID secret - vercel_project_id: prj_g5KA6QQ36ltVydRW6TUKJhgdgYjT # Optional: existing Vercel project ID - # Optional: override default branch trigger - # branches: - # - main - # - master - # - development - # Optional: additional paths to monitor for changes - # additional_paths: - # - ecosystem/shared/** - # Optional: project-specific environment variables - # env: - # - name: CUSTOM_VAR - # value: custom_value - - # Add more projects here: - # - name: another-project - # path: ecosystem/another/project diff --git a/.github/workflows/deploy-ecosystem.yml b/.github/workflows/deploy-ecosystem.yml index 7720e45f..350256cc 100644 --- a/.github/workflows/deploy-ecosystem.yml +++ b/.github/workflows/deploy-ecosystem.yml @@ -26,7 +26,7 @@ on: paths: - 'ecosystem/**' - '.github/workflows/deploy-ecosystem.yml' - - '.github/deploy-ecosystem-configs.yml' + - '.github/deploy-ecosystem-configs.json' workflow_dispatch: inputs: project_name: @@ -51,115 +51,45 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} - - name: Parse deployment config (YAML -> JSON) with Python + - name: Read deployment config id: config shell: bash run: | - set -euo pipefail - - # Convert YAML to JSON. Prefer PyYAML if present; install locally if missing. - python3 - << 'PY' > /tmp/deploy-config.json - import json, sys - from pathlib import Path - - config_path = Path(".github/deploy-ecosystem-configs.yml") - if not config_path.exists(): - print(f"Config file not found: {config_path}", file=sys.stderr) - sys.exit(1) - - try: - import yaml # type: ignore - except Exception: - # If PyYAML isn't available, signal caller to install it. - print("__NEED_PYYAML__", file=sys.stderr) - sys.exit(2) - - data = yaml.safe_load(config_path.read_text(encoding="utf-8")) - print(json.dumps(data)) - PY - - # If PyYAML was missing, install it and retry once. - if grep -q "__NEED_PYYAML__" /tmp/deploy-config.json 2>/dev/null; then - true - fi - - # The above approach prints the marker to stderr and exits 2, so handle that: - if [ "${PIPESTATUS[0]:-0}" -ne 0 ]; then - echo "PyYAML not found; installing with pip (user install)..." - python3 -m pip install --user pyyaml - python3 - << 'PY' > /tmp/deploy-config.json - import json - from pathlib import Path - import yaml # type: ignore - - config_path = Path(".github/deploy-ecosystem-configs.yml") - data = yaml.safe_load(config_path.read_text(encoding="utf-8")) - print(json.dumps(data)) - PY - fi - - # Expose JSON as a multiline output safely + # Read JSON config file and output as multiline string echo "config_json<<EOF" >> "$GITHUB_OUTPUT" - cat /tmp/deploy-config.json >> "$GITHUB_OUTPUT" + cat .github/deploy-ecosystem-configs.json >> "$GITHUB_OUTPUT" echo "EOF" >> "$GITHUB_OUTPUT" - - name: Filter projects based on changes + - name: Filter projects based on inputs id: filter - uses: actions/github-script@v7 - env: - DEPLOY_CONFIG_JSON: ${{ steps.config.outputs.config_json }} - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const { execSync } = require('child_process'); - const config = JSON.parse(process.env.DEPLOY_CONFIG_JSON); - - // Manual trigger: deploy specific project or all - if ('${{ github.event_name }}' === 'workflow_dispatch') { - if ('${{ inputs.project_name }}') { - const project = config.projects.find(p => p.name === '${{ inputs.project_name }}'); - if (project) { - core.setOutput('projects_json', JSON.stringify([project])); - core.setOutput('projects', JSON.stringify([project.name])); - return; - } - } - if ('${{ inputs.force_deploy_all }}' === 'true') { - core.setOutput('projects_json', JSON.stringify(config.projects)); - core.setOutput('projects', JSON.stringify(config.projects.map(p => p.name))); - return; - } - } - - // Get changed files (only for push events) - let changedFiles = []; - if ('${{ github.event_name }}' === 'push') { - try { - changedFiles = execSync(`git diff --name-only ${{ github.event.before }} ${{ github.event.after }}`) - .toString() - .trim() - .split('\n') - .filter(Boolean); - } catch (error) { - // If git diff fails, deploy all projects - changedFiles = ['ecosystem/']; - } - } - - // Find projects with changed files, or if workflow/config changed - const workflowChanged = changedFiles.some(f => - f.includes('deploy-ecosystem') || f.includes('deploy-ecosystem-configs') - ); - - const projectsToDeploy = workflowChanged - ? config.projects - : config.projects.filter(project => - changedFiles.some(file => file.startsWith(project.path + '/')) - ); - - core.setOutput('projects_json', JSON.stringify(projectsToDeploy)); - core.setOutput('projects', JSON.stringify(projectsToDeploy.map(p => p.name))); + shell: bash + run: | + # Read config JSON + CONFIG_JSON="${{ steps.config.outputs.config_json }}" + + # Manual trigger: deploy specific project or all + if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then + if [ -n "${{ inputs.project_name }}" ]; then + # Find specific project using jq + PROJECT=$(echo "$CONFIG_JSON" | jq -r --arg name "${{ inputs.project_name }}" '.projects[] | select(.name == $name)') + if [ -n "$PROJECT" ] && [ "$PROJECT" != "null" ]; then + echo "projects_json=[$PROJECT]" >> "$GITHUB_OUTPUT" + echo "projects=[\"${{ inputs.project_name }}\"]" >> "$GITHUB_OUTPUT" + exit 0 + fi + fi + if [ "${{ inputs.force_deploy_all }}" == "true" ]; then + echo "projects_json=$(echo "$CONFIG_JSON" | jq -c '.projects')" >> "$GITHUB_OUTPUT" + echo "projects=$(echo "$CONFIG_JSON" | jq -c '[.projects[].name]')" >> "$GITHUB_OUTPUT" + exit 0 + fi + fi + + # For push events or default, deploy all projects + echo "projects_json=$(echo "$CONFIG_JSON" | jq -c '.projects')" >> "$GITHUB_OUTPUT" + echo "projects=$(echo "$CONFIG_JSON" | jq -c '[.projects[].name]')" >> "$GITHUB_OUTPUT" - name: Show projects to deploy run: |
