An open API service indexing awesome lists of open source software.

https://github.com/coatl-dev/actions

⚡️ A collection of custom GitHub Actions.
https://github.com/coatl-dev/actions

coatl github-actions

Last synced: about 2 months ago
JSON representation

⚡️ A collection of custom GitHub Actions.

Awesome Lists containing this project

README

          

# coatl-dev GitHub Actions

[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/coatl-dev/actions/coatl.svg)](https://results.pre-commit.ci/latest/github/coatl-dev/actions/coatl)

A collection of custom GitHub Actions that are used to simplify our pipelines
in projects to keep them DRY.

## Catalog

- [gpg-import](#gpg-import)
- [pip-compile-upgrade](#pip-compile-upgrade)
- [pr-create](#pr-create)
- [pypi-upload](#pypi-upload)
- [setup-jython](#setup-jython)
- [simple-git-diff](#simple-git-diff)
- [uv-pip-compile-upgrade](#uv-pip-compile-upgrade)

### gpg-import

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**:

```yml
name: sign-commit

on:
push:
branches:
- main

jobs:
sign-commit:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v6

- name: Import GPG key
id: gpg-import
uses: coatl-dev/actions/gpg-import@v5.1.7
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"
```

### pip-compile-upgrade

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 to `pip-compile`. Optional.
Defaults to `''`.
- `working-directory` (`string`): The working directory to run the action in.
Optional. Defaults to `'.'`.

**Examples**:

```yml
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@v6

- name: pip-compile-27
uses: coatl-dev/actions/pip-compile-upgrade@v5.1.7
with:
path: "${{ env.REQUIREMENTS_PATH }}"
extra-args: '--reuse-hashes'

- name: Detect changes
id: git-diff
uses: coatl-dev/actions/simple-git-diff@v5.1.7
with:
path: "${{ env.REQUIREMENTS_PATH }}"

- name: Do something if changes were made
if: ${{ steps.git-diff.outputs.diff == 'true' }}
run: |
echo "Changes were detected."
```

### pr-create

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.
- `additional-args` (`string`): Additional arguments to pass to the
`gh pr create` command. 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:

```yml
- name: Create Pull Request
uses: coatl-dev/actions/pr-create@v5.1.7
with:
gh-token: ${{ secrets.GH_TOKEN }}
```

Passing additional arguments:

```yml
- name: Create Pull Request
uses: coatl-dev/actions/pr-create@v5.1.7
with:
gh-token: ${{ secrets.GH_TOKEN }}
additional-args: '--base develop'
```

### pypi-upload

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 to
`true`. 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 to `github.workspace`.

**Example:**

```yml
- name: Upload Python package to PyPI
uses: coatl-dev/actions/pypi-upload@v5.1.7
with:
python-version: '2.7'
check: 'false'
password: ${{ secrets.PYPI_API_TOKEN }}
```

### setup-jython

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**:

```yml
- name: Set up Jython
uses: coatl-dev/actions/setup-jython@v5.1.7
with:
jython-version: '2.7.3'
- run: jython my_script.py
```

### simple-git-diff

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**:

```yml
name: git-diff

on:
push:
branches:
- main

jobs:
sign-commit:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v6

- 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.7
with:
path: 'README.md'

- name: Do something if changes were detected
if: ${{ steps.git-diff.outputs.diff == 'true' }}
run: |
echo "Changes were detected."
```

### uv-pip-compile-upgrade

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 set `UV_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**:

```yml
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@v6

- name: pip-compile-312
uses: coatl-dev/actions/uv-pip-compile-upgrade@v5.1.7
with:
path: "${{ env.REQUIREMENTS_PATH }}"
python-version: '3.12'

- name: Detect changes
id: git-diff
uses: coatl-dev/actions/simple-git-diff@v5.1.7
with:
path: "${{ env.REQUIREMENTS_PATH }}"

- name: Do something if changes were made
if: ${{ steps.git-diff.outputs.diff == 'true' }}
run: |
echo "Changes were detected."
```

[`coatl-dev/python-tools:2.7-pip-tools`]: https://github.com/coatl-dev/docker-python-tools/blob/coatl/pip-tools/2.7/Dockerfile
[`git diff`]: https://git-scm.com/docs/git-diff
[supported Java distributions]: https://github.com/actions/setup-java#supported-distributions
[supported Jython versions]: https://repo1.maven.org/maven2/org/python/jython-installer/