From 4ac226192a7f2bb7cccf539b7c0b8c5c19e8df59 Mon Sep 17 00:00:00 2001 From: hoangvv Date: Fri, 10 Jan 2025 09:32:52 +0700 Subject: [PATCH] update --- .github/workflows/setup_docker.yml | 2 +- setup/clean_up_virtualenvs.sh | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100755 setup/clean_up_virtualenvs.sh diff --git a/.github/workflows/setup_docker.yml b/.github/workflows/setup_docker.yml index 5dee9ce96..b4627cc8b 100644 --- a/.github/workflows/setup_docker.yml +++ b/.github/workflows/setup_docker.yml @@ -20,7 +20,7 @@ jobs: with: ref: ${{ github.ref_name }} - name: Create Virtual Environment - run: pyenv virtualenv "$(git rev-parse --short "$GITHUB_SHA")" + run: /home/nextzen/.pyenv/bin/pyenv virtualenv "${{ github.ref_name }}-$(git rev-parse --short "$GITHUB_SHA")" - name: Install dotenv run: pip install python-dotenv diff --git a/setup/clean_up_virtualenvs.sh b/setup/clean_up_virtualenvs.sh new file mode 100755 index 000000000..86613e6d8 --- /dev/null +++ b/setup/clean_up_virtualenvs.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# Get the current branch name +branch_name=$(git rev-parse --abbrev-ref HEAD) + +# Get a list of all virtual environments, filtering out duplicates +virtualenvs=$(pyenv virtualenvs | awk '{print $1}' | sort -u) + +# Loop through each virtual environment and delete it if it contains the branch name +for venv in $virtualenvs; do + if [[ "$venv" == *"$branch_name"* ]]; then + echo "Deleting virtual environment: $venv" + pyenv virtualenv-delete "$venv" -f + fi +done + +echo "Virtual environments containing '$branch_name' deleted." \ No newline at end of file