-
Notifications
You must be signed in to change notification settings - Fork 1
94 lines (78 loc) · 2.62 KB
/
python.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
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
name: ♻ python
on:
workflow_call:
inputs:
runs_on:
description: The label of the runner (GitHub- or self-hosted) to run this workflow on. Defaults to `ubuntu-24.04`.
type: string
required: false
default: ubuntu-24.04
working_directory:
description: The path of the directory containing the Python application.
type: string
required: false
default: "."
python_version:
description: The version of Python to install.
type: string
required: false
default: latest
venv_path:
description: The path to create a virtual Python environment at (relative to working directory).
type: string
required: false
pip_install_target:
description: The target directory that PIP should install packages into (relative to working directory).
type: string
required: false
artifact_name:
description: The name of the build artifact to upload.
type: string
required: false
default: python-app
outputs:
artifact_name:
description: The name of the uploaded artifact containing the application.
value: ${{ inputs.artifact_name }}
permissions: {}
jobs:
python:
name: Python
runs-on: ${{ inputs.runs_on }}
permissions:
contents: read # Required to checkout the repository
defaults:
run:
shell: bash
working-directory: ${{ inputs.working_directory }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Setup Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b
with:
python-version: ${{ inputs.python_version }}
- name: Create and activate virtual environment
if: inputs.venv_path != ''
env:
VENV_PATH: ${{ inputs.venv_path }}
run: |
python -m venv "$VENV_PATH"
source "$VENV_PATH/bin/activate"
- name: Install dependencies
env:
TARGET: ${{ inputs.pip_install_target }}
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt --target "$TARGET"
- name: Create tarball
id: tar
run: |
tarball="$RUNNER_TEMP/$ARTIFACT_NAME.tar"
tar -cvf "$tarball" .
echo "tarball=$tarball" >> "$GITHUB_OUTPUT"
- name: Upload artifact
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
with:
name: ${{ inputs.artifact_name }}
path: ${{ steps.tar.outputs.tarball }}