-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
62 lines (60 loc) · 1.95 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
name: 'Install dependencies with Poetry'
description: 'Install dependencies using Poetry.'
author: '@ouhammmourachid'
branding:
icon: 'truck'
color: 'blue'
inputs:
python-version:
description: 'The version of Python to use.'
required: true
default: '3.10'
poetry-version:
description: 'The version of Poetry to use.'
required: true
default: 'latest'
extra-args:
description: 'Extra arguments to pass to the `poetry install` command.'
required: false
default: ''
runs:
using: 'composite'
steps:
# Step 1: Set up Python
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
# Step 2: Install Poetry
- name: Install and configure Poetry
uses: snok/install-poetry@v1.4.1
with:
version: ${{ inputs.poetry-version }}
# Step 3: create a virtual environment
- name: Create a virtual environment
run: |
poetry env use python
poetry env info
shell: bash
- name: Add Poetry to PATH
run: |
echo "C:\Users\runneradmin\.local\bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
shell: pwsh
if: runner.os == 'Windows'
# Step 4: Cache Poetry dependencies
- name: Cache Poetry dependencies
uses: actions/cache@v4
with:
path: |
${{ runner.os == 'Windows' && 'C:\Users\runneradmin\AppData\Local\pypoetry' }}
${{ runner.os == 'Linux' && '~/.cache/pypoetry' }}
${{ runner.os == 'macOS' && '~/Library/Caches/pypoetry' }}
key: pypoetry-${{inputs.python-version}}-${{inputs.poetry-version}}-${{runner.os}}-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
pypoetry-${{inputs.python-version}}-${{inputs.poetry-version}}-${{runner.os}}-
# Step 5: Install dependencies
- name: Install dependencies
run: |
poetry install ${{ inputs.extra-args }}
poetry show
shell: bash