# .gitlab-ci.yml # Define the stages for the pipeline. We only need one for this task. stages: - analyze # This is the main job that will run the DSS analysis. dss_context_update: stage: analyze # Use a Docker image that has Python and Node.js. # 'node:18-bullseye' is a good choice as it has a recent Node.js and Python 3.9+. image: node:18-bullseye # before_script runs before the main 'script' section. # It's used for setup and configuration. before_script: - echo "Setting up the environment for DSS..." # Update package lists and install Git and Python pip - apt-get update && apt-get install -y git python3-pip # Install Python dependencies - pip3 install -r requirements.txt # Install Node.js dependencies (within the dss-mvp1 directory) - cd dss-mvp1 && npm install && cd .. # --- Git Configuration --- # Configure Git with a dedicated user for the DSS agent. # This makes it clear which commits are automated. - git config --global user.email "dss-agent@your-gitlab-instance.com" - git config --global user.name "DSS Agent" # The main part of the job. script: - echo "Running DSS project analysis..." # Run the DSS CLI to analyze the project. # The output of this command will be the updated project_context.json file. - python3 dss-mvp1/dss-cli.py analyze --project-path . # --- Commit and Push Changes --- # Check if the analysis generated any changes to the context file. # 'git status --porcelain' provides a clean, scriptable output. - | if git status --porcelain | grep -q '.dss/analysis_graph.json'; then echo "Change detected in analysis_graph.json. Committing and pushing..." # Add the file to the staging area. git add .dss/analysis_graph.json # Commit the changes with a standardized message. git commit -m "chore(dss): Update project analysis context [skip ci]" # Push the commit back to the same branch. # We use the GITLAB_TOKEN we configured earlier for authentication. # The [skip ci] in the commit message prevents this push from triggering a new pipeline run, avoiding an infinite loop. git push "https://gitlab-ci-token:${GITLAB_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git" "HEAD:${CI_COMMIT_REF_NAME}" else echo "No changes detected in project context. Nothing to commit." fi # Rules define when this job should run. rules: # Run the job for any pushes to branches (but not tags). - if: '$CI_COMMIT_TAG == null'