Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tmclaugh committed Sep 1, 2024
0 parents commit cafcaab
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/branch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Branch

on:
workflow_dispatch:
push:
branches:
- '*'
branches-ignore:
- 'main'

jobs:
build:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read

steps:
- name: Action Lint
id: action-lint
uses: raven-actions/actionlint@v2
with:
files: 'action.yml'
pyflakes: false
22 changes: 22 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Main

on:
workflow_dispatch:
push:
branches:
- 'main'

jobs:
build:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read

steps:
- name: Action Lint
id: action-lint
uses: raven-actions/actionlint@v2
with:
files: 'action.yml'
pyflakes: false
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# gha-setup-python
This GitHub Action sets up a Python environment for use in workflows.

_*NOTE: This workflow is opinionated and meets the needs of its author. It is provided publicly as a reference for others to use and modify as needed.*_

This action will perform the following actions:
* Install Python
* Install Pipenv
* Generate Pipfile.lock if does not exist (only to be used in that run)
* Install dependencies

## Usage
To use this action, add the following step to your workflow:

```yaml
steps:
- name: Checkout code
uses: serverlessopsio/gha-setup-workspace@v1

- name: Setup Python enviornment
uses: serverlessopsio/gha-setup-python@v1
```
## Inputs
* python-version (_optional_): The version of Python to use. This action uses the version resolution employed by [actions/setup-python](https://github.com/actions/setup-python)
## Outputs
* python-version: he installed Python or PyPy version. Useful when given a version range as input.
* cache-hit: A boolean value to indicate a cache entry was found
* python-path: The absolute path to the Python or PyPy executable.
## Contributing
Contributions are welcome! Please open an issue or submit a pull request for any changes.
## Contact
For any questions or support, please open an issue in this repository.
45 changes: 45 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

name: setup-python
description: Installs Python and project dependencies

inputs:
python_version:
description: Python version

runs:
using: composite

steps:
- name: Setup Python
id: install-python
uses: actions/setup-python@v4
with:
python-version: '${{ inputs.python_version }}'
cache: pipenv

- name: Install pipenv
id: install-pipenv
shell: bash
run: pip install --user --upgrade pipenv

# This is to ensure that all jobs in a workflow will resolve the same dependencies
- name: Check Pipfile.lock
id: check-pipfile-lock
shell: bash
run: |
if [ -f Pipfile.lock ]; \
then \
echo "has-lock=true" >> $GITHUB_OUTPUT; \
else \
echo "has-lock=false" >> $GITHUB_OUTPUT; \
fi
- name: Install dependencies
id: install-python-deps
shell: bash
run: pipenv install --dev

outputs:
python-version: ${{ steps.install-python.outputs.python-version }}
python-path: ${{ steps.install-python.outputs.python-path }}
cache-hit: ${{ steps.install-python.outputs.cache-hit }}

0 comments on commit cafcaab

Please sign in to comment.