-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaction.yml
41 lines (30 loc) · 962 Bytes
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
name: 'setup_python_venv'
description: 'Setup a Python virtual environment and add it to the PATH'
inputs:
path:
description: 'Path to virtual environment'
required: false
default: '.venv'
activate_global:
description: 'Activate the virtual environment globally'
required: false
default: true
runs:
using: composite
steps:
- name: 'setup_python_venv'
run: |
echo "::group::Setup Python virtual environment"
if [ -d "${{ inputs.path }}" ] && [ -f "${{ inputs.path }}/bin/activate" ]; then
echo "Virtual environment exists."
else
# Create a virtual environment
python3 -m venv ${{ inputs.path }}
fi
# Activate the virtual environment
source ${{ inputs.path }}/bin/activate
if [ "${{ inputs.activate_global }}" = "true" ]; then
echo PATH=$PATH >> $GITHUB_ENV
fi
echo "::endgroup::"
shell: bash