@@ -60,30 +60,40 @@ runs:
6060 echo "SCANCODEIO_DB_USER=scancodeio" >> $GITHUB_ENV
6161 echo "SCANCODEIO_DB_PASSWORD=scancodeio" >> $GITHUB_ENV
6262
63+ - name : Detect if ScanCode.io is already installed
64+ shell : bash
65+ run : |
66+ if command -v scanpipe &> /dev/null; then
67+ echo "ScanCode.io already installed."
68+ echo "SCANCODEIO_IS_INSTALLED=true" >> $GITHUB_ENV
69+ else
70+ echo "ScanCode.io not found."
71+ echo "SCANCODEIO_IS_INSTALLED=false" >> $GITHUB_ENV
72+ fi
73+
6374 - name : Start and setup the PostgreSQL service
75+ if : env.SCANCODEIO_IS_INSTALLED != 'true'
6476 shell : bash
6577 run : |
6678 sudo systemctl start postgresql.service
67- sudo -u postgres createuser --no-createrole --no-superuser --login --inherit --createdb ${{ env.SCANCODEIO_DB_USER }} || true
68- sudo -u postgres psql -c "ALTER USER ${{ env.SCANCODEIO_DB_USER }} WITH ENCRYPTED PASSWORD '${{ env.SCANCODEIO_DB_PASSWORD }}'" || true
69- sudo -u postgres createdb --owner=scancodeio --encoding=UTF-8 ${{ env.SCANCODEIO_DB_NAME }} || true
79+ sudo -u postgres createuser --no-createrole --no-superuser --login --inherit --createdb ${{ env.SCANCODEIO_DB_USER }}
80+ sudo -u postgres psql -c "ALTER USER ${{ env.SCANCODEIO_DB_USER }} WITH ENCRYPTED PASSWORD '${{ env.SCANCODEIO_DB_PASSWORD }}'"
81+ sudo -u postgres createdb --owner=scancodeio --encoding=UTF-8 ${{ env.SCANCODEIO_DB_NAME }}
7082
7183 - name : Install ScanCode.io (only if not already installed)
84+ if : env.SCANCODEIO_IS_INSTALLED != 'true'
7285 shell : bash
7386 run : |
74- if ! command -v scanpipe &> /dev/null; then
75- if [ -z "${{ inputs.scancodeio-repo-branch }}" ]; then
76- echo "Installing the latest ScanCode.io release from PyPI"
77- pip install --upgrade scancodeio
78- else
79- echo "Installing ScanCode.io from the GitHub branch: ${{ inputs.scancodeio-repo-branch }}"
80- pip install git+https://github.com/aboutcode-org/scancode.io.git@${{ inputs.scancodeio-repo-branch }}
81- fi
87+ if [ -z "${{ inputs.scancodeio-repo-branch }}" ]; then
88+ echo "Installing the latest ScanCode.io release from PyPI"
89+ pip install --upgrade scancodeio
8290 else
83- echo "ScanCode.io already installed, skipping installation."
91+ echo "Installing ScanCode.io from the GitHub branch: ${{ inputs.scancodeio-repo-branch }}"
92+ pip install git+https://github.com/aboutcode-org/scancode.io.git@${{ inputs.scancodeio-repo-branch }}
8493 fi
8594
8695 - name : Run migrations to prepare the database
96+ if : env.SCANCODEIO_IS_INSTALLED != 'true'
8797 shell : bash
8898 run : scanpipe migrate --verbosity 0
8999
0 commit comments