-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: Add a new action to setup Python and pontos in a virtualenv
We have several actions and workflows that use the latest release of pontos under the hood. Therefore unify the setup and installation of pontos in a single action. This allows reusing the virtual environment and caching. Therefore it will result in faster action runs.
- Loading branch information
1 parent
853ed4f
commit 9802104
Showing
6 changed files
with
111 additions
and
112 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Setup Pontos Action | ||
|
||
GitHub Action to setup [pontos](https://github.com/greenbone/pontos) for your | ||
action or workflow. | ||
|
||
```yml | ||
name: Conventional Commits | ||
|
||
on: | ||
pull_request: | ||
|
||
permissions: | ||
pull-requests: write | ||
contents: read | ||
|
||
jobs: | ||
conventional-commits: | ||
name: Report Conventional Commits | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Report Conventional Commits | ||
uses: greenbone/actions/conventional-commits@v2 | ||
with: | ||
token: ${{ secrets.SOME_TOKEN }} | ||
``` | ||
## Action Configuration | ||
|Input Variable|Description| | | ||
|--------------|-----------|-| | ||
| token | GitHub token to create the pull request comments. | Optional (default is [`github.token`](https://docs.github.com/en/actions/learn-github-actions/contexts#github-context)) | | ||
| python-version | Python version to use for running the action. | Optional (default is `3.10`) | | ||
| poetry-version | Poetry version to use for running the action. | Optional (default is latest) | | ||
| cache-poetry-installation | Cache poetry and its dependencies. | Optional (default is `true`) | |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: "Setup Pontos Action" | ||
author: "Björn Ricks <bjoern.ricks@greenbone.net>" | ||
description: "An action to setup python and pontos" | ||
inputs: | ||
cache-key: | ||
description: "Key to use for the cache name." | ||
default: "pontos-venv" | ||
python-version: | ||
description: "Python version that should be installed and used." | ||
default: "3.10" | ||
virtualenv-path: | ||
description: "Path to the created virtual environment" | ||
default: "${{ github.workspace }}/pontos-env" | ||
|
||
outputs: | ||
virtualenv-path: | ||
description: "Path to the created virtual environment" | ||
value: ${{ steps.virtualenv.outputs.path }} | ||
activate: | ||
description: "Path to the activate environment script to source" | ||
value: ${{ steps.virtualenv.outputs.activate }} | ||
|
||
branding: | ||
icon: "package" | ||
color: "green" | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Virtual Environment | ||
id: virtualenv | ||
run: | | ||
echo "path=${{ inputs.virtualenv-path }}" >> $GITHUB_OUTPUT | ||
echo "activate=${{ inputs.virtualenv-path }}/bin/activate" >> $GITHUB_OUTPUT | ||
shell: bash | ||
- name: Set up Python ${{ inputs.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ inputs.python-version }} | ||
- name: Cache Virtual Environment | ||
id: cache-virtualenv | ||
uses: actions/cache@v3 | ||
with: | ||
key: ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ inputs.cache-key }} | ||
path: ${{ steps.virtualenv.outputs.path }} | ||
- name: Create virtual environment | ||
if: ${{ steps.cache-virtualenv.outputs.cache-hit != 'true' }} | ||
run: | | ||
python3 -m venv ${{ steps.virtualenv.outputs.path }} | ||
shell: bash | ||
- name: Install pontos | ||
run: | | ||
source ${{ steps.virtualenv.outputs.activate }} | ||
python3 -m pip install --upgrade pip | ||
python3 -m pip install --upgrade pontos | ||
shell: bash | ||
- name: Print pontos version | ||
run: | | ||
source ${{ steps.virtualenv.outputs.activate }} | ||
pontos --version | ||
shell: bash |
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