Created
April 7, 2023 02:47
-
-
Save gh640/317865611e39b93442579ed3cd4491ce to your computer and use it in GitHub Desktop.
Sample: Composite action to install Python and Poetry on GitHub Actions workflows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 'Install Python and Poetry' | |
description: 'Add Poetry, dependency manager for Python' | |
inputs: | |
python-version: | |
description: 'Python version' | |
required: true | |
poetry-version: | |
description: 'Poetry version' | |
required: true | |
runs: | |
using: 'composite' | |
steps: | |
- name: Set up Python ${{ inputs.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ inputs.python-version }} | |
id: setup_python | |
- name: Install Poetry ${{ inputs.poetry-version }} | |
run: | | |
curl -sSL ${{ env.POETRY_URL }} | \ | |
python - --version ${{ inputs.poetry-version }} | |
echo "$HOME/.local/bin" >> $GITHUB_PATH | |
shell: bash | |
env: | |
POETRY_URL: https://install.python-poetry.org | |
- name: Cache Poetry cache | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pypoetry | |
key: poetry-cache-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ inputs.poetry-version }} | |
- name: Cache Packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.local | |
key: poetry-local-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}-${{ hashFiles('.github/workflows/*.yml') }} |
Alternatively, there is a Github Action that does this
https://github.com/packetcoders/action-setup-cache-python-poetry
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage
<project_root>/.github/actions/setup-python-poetry/action.yml
This might not work in the future due to GitHub Actions changes.