Skip to content

Commit 8036126

Browse files
committed
simplify the postgres and refine
Signed-off-by: tdruez <tdruez@aboutcode.org>
1 parent 791d653 commit 8036126

2 files changed

Lines changed: 11 additions & 13 deletions

File tree

.github/workflows/multi-runs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,5 @@ jobs:
4242
which scanpipe || { echo "scanpipe not found in PATH"; exit 1; }
4343
which scancode || { echo "scancode not found in PATH"; exit 1; }
4444
echo "Versions:"
45+
scanpipe --version
4546
scanpipe shell -c "import scancodeio; from scancode_config import __version__ as scancode_version;print(f'ScanCode.io version: {scancodeio.__version__}');print(f'ScanCode-toolkit version: v{scancode_version}')"

action.yml

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,23 +83,24 @@ runs:
8383
INPUT_IMAGE: ${{ inputs.scancodeio-image }}
8484
run: |
8585
echo "SECRET_KEY=$(openssl rand -base64 32)" >> "$GITHUB_ENV"
86-
echo "SCANCODEIO_DB_NAME=scancodeio" >> "$GITHUB_ENV"
87-
echo "SCANCODEIO_DB_USER=scancodeio" >> "$GITHUB_ENV"
88-
echo "SCANCODEIO_DB_PASSWORD=scancodeio" >> "$GITHUB_ENV"
8986
# Workspace location mounted into the container, so outputs are directly accessible
9087
echo "SCANCODEIO_WORKSPACE_LOCATION=/workspace/.scancodeio" >> "$GITHUB_ENV"
9188
echo "SCANCODEIO_IMAGE=$INPUT_IMAGE" >> "$GITHUB_ENV"
9289
# Sanitize project name for artifact usage
93-
SAFE_PROJECT_NAME="${INPUT_PROJECT_NAME//[^a-zA-Z0-9._-]/_}"
94-
echo "SAFE_PROJECT_NAME=$SAFE_PROJECT_NAME" >> "$GITHUB_ENV"
90+
echo "SAFE_PROJECT_NAME=${INPUT_PROJECT_NAME//[^a-zA-Z0-9._-]/_}" >> "$GITHUB_ENV"
9591
9692
- name: Start and setup the PostgreSQL service
9793
shell: bash
9894
run: |
99-
sudo systemctl start postgresql.service
100-
sudo -u postgres createuser --no-createrole --no-superuser --login --inherit --createdb "$SCANCODEIO_DB_USER"
101-
sudo -u postgres psql -c "ALTER USER $SCANCODEIO_DB_USER WITH ENCRYPTED PASSWORD '$SCANCODEIO_DB_PASSWORD'"
102-
sudo -u postgres createdb --owner=scancodeio --encoding=UTF-8 "$SCANCODEIO_DB_NAME"
95+
if ! sudo systemctl is-active --quiet postgresql; then
96+
sudo systemctl start postgresql.service
97+
sudo -u postgres psql -c "CREATE USER scancodeio WITH CREATEDB ENCRYPTED PASSWORD scancodeio;"
98+
sudo -u postgres createdb --owner=scancodeio --encoding=UTF-8 scancodeio
99+
fi
100+
101+
- name: Pull the ScanCode.io image
102+
shell: bash
103+
run: docker pull "$SCANCODEIO_IMAGE"
103104

104105
- name: Write scanpipe wrapper script
105106
shell: bash
@@ -122,10 +123,6 @@ runs:
122123
chmod +x "$RUNNER_TEMP/scanpipe"
123124
echo "$RUNNER_TEMP" >> "$GITHUB_PATH"
124125
125-
- name: Pull the ScanCode.io image
126-
shell: bash
127-
run: docker pull "$SCANCODEIO_IMAGE"
128-
129126
- name: Run migrations to prepare the database
130127
shell: bash
131128
run: scanpipe migrate --verbosity 0

0 commit comments

Comments
 (0)