diff --git a/workflow-templates/sync_app_panel.properties.json b/workflow-templates/sync_app_panel.properties.json new file mode 100644 index 0000000..697fd98 --- /dev/null +++ b/workflow-templates/sync_app_panel.properties.json @@ -0,0 +1,11 @@ +{ + "name": "Sync App Panel", + "description": "Auto-generate CodeOcean app-panel.json from a library's BaseSettings or argparse class using auto-app-panel", + "iconName": "mouse_robot", + "categories": [ + "Python", "CodeOcean", "CI" + ], + "filePatterns": [ + ".codeocean/app-panel.json" + ] +} \ No newline at end of file diff --git a/workflow-templates/sync_app_panel.yml b/workflow-templates/sync_app_panel.yml new file mode 100644 index 0000000..30ed3ad --- /dev/null +++ b/workflow-templates/sync_app_panel.yml @@ -0,0 +1,64 @@ +name: Sync App Panel + +on: + push: + branches: + - $default-branch + workflow_dispatch: + +jobs: + sync-app-panel: + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - name: Checkout capsule repo + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install library from environment.json + run: | + pip install auto-app-panel + pip install $(python -c " + import json + env = json.load(open('.codeocean/environment.json')) + for pkg in env['installers']['pip']['packages']: + print(f\"{pkg['name']}=={pkg['version']}\") + ") + + # Configure: set SOURCE to the module containing your BaseSettings/argparse class + # EG: local file: "code/run_capsule.py" + # EG: installed package: "my_package/settings.py" (gets resolved from site-packages) + # --strategy [overwrite|preserve] - Merge strategy (default: preserve) + # overwrite: Updates parameter values from code, preserves existing descriptions + # preserve: Keeps all existing values, only adds new parameters + # --no-backup - Skip creating timestamped backup of existing file + # https://pypi.org/project/auto-app-panel/ + - name: Run auto-app-panel + run: | + SOURCE="your_package/your_module.py" + if [ -f "$SOURCE" ]; then + TARGET="$SOURCE" + else + SITE=$(python -c "import sysconfig; print(sysconfig.get_path('purelib'))") + TARGET="$SITE/$SOURCE" + fi + auto-app-panel \ + "$TARGET" \ + .codeocean/app-panel.json \ + --strategy preserve \ + --no-backup + + - name: Commit changes (if any) + run: | + git diff --quiet .codeocean/app-panel.json && exit 0 + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add .codeocean/app-panel.json + git commit -m "ci: sync app-panel.json [skip actions]" + git push