-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yaml
128 lines (107 loc) · 3.44 KB
/
action.yaml
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: 'Setup Python Env'
description: 'Setup Python Environment'
author: "CDQ AG"
branding:
icon: 'hard-drive'
color: 'blue'
inputs:
python-version:
description: 'Version of Python to use'
default: '3.10.14'
use-local-python3-if-possible:
description: 'Should use local Python 3 if possible?'
default: 'false'
setup-virtualenv:
description: 'Setup virtualenv'
default: 'false'
virtualenv-dir:
description: 'Directory to setup virtualenv'
default: '.venv'
install-poetry:
description: 'Install Poetry'
default: 'false'
poetry-version:
description: 'Version of Poetry to use'
default: '1.8.1'
index-url:
description: 'Index URL to set for pip - set empty to skip'
default: ''
install-dependencies:
description: 'Install dependencies - skip if false; if install-poetry is true, it will use poetry to install dependencies, otherwise pip'
default: 'true'
install-packages:
description: 'Install packages'
default: ''
runs:
using: 'composite'
steps:
- name: Check available Python
id: check
shell: bash
env:
USE_LOCAL_PYTHON_IF_POSSIBLE: ${{ inputs.use-local-python3-if-possible }}
run: |
if [[ "$USE_LOCAL_PYTHON_IF_POSSIBLE" == "true" ]]; then
if [ -x "$(command -v python3)" ]; then
echo "Local Python 3 is available"
echo "localPython=true" >> $GITHUB_OUTPUT
else
echo "Local Python 3 is not available"
echo "localPython=false" >> $GITHUB_OUTPUT
fi
else
echo "Not using Python 3"
echo "localPython=false" >> $GITHUB_OUTPUT
fi
- if: ${{ steps.check.outputs.localPython != 'true' }}
id: setup-python
name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
update-environment: false
- if: ${{ steps.check.outputs.localPython != 'true' }}
name: Post installation
shell: bash
env:
PYTHON_PATH: ${{ steps.setup-python.outputs.python-path }}
run: |
echo "PATH=$PYTHON_PATH:$PATH" >> $GITHUB_ENV
- if: ${{ inputs.setup-virtualenv == 'true' }}
name: Setup Virtual Envitonment
shell: bash
env:
VENV_DIR: ${{ inputs.virtualenv-dir }}
run: |
if [ ! -x "$(command -v virtualenv)" ]; then
python3 -m pip install --user virtualenv
fi
if [ ! -d "$VENV_DIR" ]; then
python3 -m virtualenv $VENV_DIR
fi
echo "PATH=$(pwd)/$VENV_DIR/bin:$PATH" >> $GITHUB_ENV
- if: ${{ inputs.install-poetry == 'true' }}
name: Install Poetry
shell: bash
run: |
pip install poetry==${{ inputs.poetry-version }}
- if: ${{ inputs.index-url != '' }}
name: Set index URL
shell: bash
run: |
echo "PIP_INDEX_URL=${{ inputs.index-url }}" >> $GITHUB_ENV
- if: ${{ inputs.install-dependencies == 'true' && inputs.install-poetry == 'true' }}
name: Install dependencies with poetry
shell: bash
run: |
poetry install
- if: ${{ inputs.install-dependencies == 'true' && inputs.install-poetry != 'true' }}
name: Install dependencies with pip
shell: bash
run: |
pip install -r requirements.txt
- if: ${{ inputs.install-packages != '' }}
name: Install packages
shell: bash
run: |
pip install ${{ inputs.install-packages }}