A collection of custom GitHub Actions that are used to simplify our pipelines in projects to keep them DRY.
- gpg-import
- pip-compile-upgrade
- pr-create
- pypi-upload
- setup-jython
- simple-git-diff
- uv-pip-compile-upgrade
GitHub Action to import GPG private key.
Inputs:
config-git
(string
): Whether to config Git to sign commits with the information obtained from GPG. Options:'yes'
,'no'
. Defaults to'yes'
. Optional.passphrase
(secret
): GPG private key passphrase. Required.private-key
(secret
): GPG private key exported as an ASCII armored version. Required.
Outputs:
git-user-email
(string
): Email address used for setting up Git identity.git-user-name
(string
): Name used for setting up Git identity.gpg-key-id
(string
): The long form of the GPG key ID.
Example:
name: sign-commit
on:
push:
branches:
- main
jobs:
sign-commit:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Import GPG key
id: gpg-import
uses: coatl-dev/actions/gpg-import@v5.1.0
with:
passphrase: ${{ secrets.GPG_PASSPHRASE }}
private-key: ${{ secrets.GPG_PRIVATE_KEY }}
- name: Make changes
run: |
# Your changes go here
- name: Sign commit
run: |
# Creates a signed commit
git commit -m "YOUR_COMMIT_MESSAGE"
Run pip-compile upgrade
to upgrade your Python 2.7.18 requirements using
coatl-dev/python-tools:2.7-pip-tools
Docker image.
The pip-compile
command lets you compile a requirements.txt
file from your
dependencies, specified in either setup.py
or requirements.in
.
Inputs:
path
(string
): The location of the requirement file(s).extra-args
(string
): Extra arguments to pass topip-compile
. Optional. Defaults to''
.working-directory
(string
): The working directory to run the action in. Optional. Defaults to'.'
.
Examples:
name: pip-compile-27
on:
schedule:
# Monthly at 12:00 PST (00:00 UTC)
- cron: '0 20 1 * *'
jobs:
pip-compile:
runs-on: ubuntu-latest
env:
REQUIREMENTS_PATH: 'path/to/requirements'
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: pip-compile-27
uses: coatl-dev/actions/pip-compile-upgrade@v5.1.0
with:
path: "${{ env.REQUIREMENTS_PATH }}"
extra-args: '--reuse-hashes'
- name: Detect changes
id: git-diff
uses: coatl-dev/actions/simple-git-diff@v5.1.0
with:
path: "${{ env.REQUIREMENTS_PATH }}"
- name: Do something if changes were made
if: ${{ steps.git-diff.outputs.diff == 'true' }}
run: |
echo "Changes were detected."
GitHub Action to create Pull Request using gh.
Inputs:
gh-token
(secret
): GitHub token. Required.title
(string
): Title for the pull request. Optional.body
(string
): Body for the pull request. Optional.body-file
(string
): Read body text from file. Optional.auto-merge
(string
): Automatically merge only after necessary requirements are met. Options:'yes'
,'no'
. Defaults to'yes'
. Optional.delete-branch
(string
): Delete the local and remote branch after merge. Options:'yes'
,'no'
. Defaults to'no'
. Optional.
Important
If all optional inputs are missing, gh
will use the commit message and body
and run gh pr create --fill
.
Example:
Add this step to your workflow:
- name: Create Pull Request
uses: coatl-dev/actions/pr-create@v5.1.0
with:
gh-token: ${{ secrets.GH_TOKEN }}
GitHub action to build and upload your Python distribution packages to PyPI
(or any other repository) using build
and twine
.
Note
This action uses the [ghcr.io/coatl-dev/python-tools
] Docker image, which
has tags for Python 2.7 and 3.12. E.g.,
ghcr.io/coatl-dev/python-tools:2.7-build
.
Inputs:
python-version
(string
): The Python version to use for building and publishing the package. Options:'2.7'
or'3.12'
. Defaults to'2.7'
. Optional.check
(boolean
): Check metadata with twine before uploading. Defaults totrue
. Optional.url
(string
): The repository (package index) URL to upload the package to. Defaults to'https://upload.pypi.org/legacy/'
. Optional.username
(string
): The username to authenticate to the repository (package index) as. Defaults to'__token__'
. Optional.password
(secret
): The password to authenticate to the repository (package index) with. This can also be a token. Required.working-directory
(string
): The directory to run the action in. Optional. Defaults togithub.workspace
.
Example:
- name: Upload Python package to PyPI
uses: coatl-dev/actions/pypi-upload@v5.1.0
with:
python-version: '2.7'
check: 'false'
password: ${{ secrets.PYPI_API_TOKEN }}
Set up a specific version of Jython and add the command-line tools to the PATH.
Tip
This action also sets the JYTHON_HOME
environment variable.
Inputs:
jython-version
(string
): The Jython version to install. Defaults to'2.7.4'
. Optional. See supported Jython versions.java-distribution
(string
): Java distribution to use for installing Jython. Defaults to'temurin'
. Optional. See supported Java distributions.java-version
(string
): The Java version to set up. Defaults to'17'
. Optional.
Outputs:
jython-version
(string
): The installed Jython version.jython-path
(string
): The absolute path to the Jython executable.java-distribution
(string
):Distribution of Java that has been installed.java-version
(string
): Actual version of the java environment that has been installed.java-path
(string
): Path to where the java environment has been installed (same as $JAVA_HOME).
Example:
- name: Set up Jython
uses: coatl-dev/actions/setup-jython@v5.1.0
with:
jython-version: '2.7.3'
- run: jython my_script.py
Run git diff
on a file or path.
Inputs:
path
(string
): File or path to check for changes. Defaults to'.'
. Optional.
Outputs:
diff
(string
): Whether files were changed between commits. Returns:'true'
or'false'
.
Example:
name: git-diff
on:
push:
branches:
- main
jobs:
sign-commit:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Modify file in repo
run: |
echo "New line" >> README.md
- name: Detect changes
id: git-diff
uses: coatl-dev/actions/simple-git-diff@v5.1.0
with:
path: 'README.md'
- name: Do something if changes were detected
if: ${{ steps.git-diff.outputs.diff == 'true' }}
run: |
echo "Changes were detected."
Run uv pip compile-upgrade
to upgrade your Python requirements.
The uv pip compile
command lets you compile a requirements.txt
file from
your dependencies, specified in either pyproject.toml
, setup.cfg
,
setup.py
, or requirements.in
.
Inputs:
path
(string
): The location of the requirement file(s).python-version
(string
): The version of Python to setUV_PYTHON
to. You may use MAJOR.MINOR or exact version. Options:'3.8'
to'3.14'
. Defaults to'3.13'
. Optional.uv-version
(string
): The version of uv to install. Defaults to'latest'
. Optional.working-directory
(string
): The working directory to run the action in. Optional. Defaults to'.'
.
Example:
name: uv-pip-compile
on:
schedule:
# Monthly at 12:00 PST (00:00 UTC)
- cron: '0 20 1 * *'
jobs:
pip-compile:
runs-on: ubuntu-latest
env:
REQUIREMENTS_PATH: 'path/to/requirements'
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: pip-compile-312
uses: coatl-dev/actions/uv-pip-compile-upgrade@v5.1.0
with:
path: "${{ env.REQUIREMENTS_PATH }}"
python-version: '3.12'
- name: Detect changes
id: git-diff
uses: coatl-dev/actions/simple-git-diff@v5.1.0
with:
path: "${{ env.REQUIREMENTS_PATH }}"
- name: Do something if changes were made
if: ${{ steps.git-diff.outputs.diff == 'true' }}
run: |
echo "Changes were detected."