https://github.com/cssnr/actions-tools
A Typed Python GitHub Actions Tookit similar to actions/toolkit
https://github.com/cssnr/actions-tools
actions python
Last synced: 3 months ago
JSON representation
A Typed Python GitHub Actions Tookit similar to actions/toolkit
- Host: GitHub
- URL: https://github.com/cssnr/actions-tools
- Owner: cssnr
- License: gpl-3.0
- Created: 2025-02-20T02:59:24.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-11-29T08:31:46.000Z (6 months ago)
- Last Synced: 2025-12-21T23:16:05.039Z (5 months ago)
- Topics: actions, python
- Language: Python
- Homepage: http://actions-tools.cssnr.com/
- Size: 166 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Support: docs/support.md
Awesome Lists containing this project
README
[](https://pypi.org/project/actions-tools/)
[](https://github.com/cssnr/actions-tools/releases)
[](https://github.com/cssnr/actions-tools?tab=readme-ov-file#readme)
[](https://pypistats.org/packages/actions-tools)
[](https://clickpy.clickhouse.com/dashboard/actions-tools)
[](https://codecov.io/gh/cssnr/actions-tools)
[](https://sonarcloud.io/summary/new_code?id=cssnr_actions-tools)
[](https://github.com/cssnr/actions-tools/actions/workflows/test.yaml)
[](https://github.com/cssnr/actions-tools/actions/workflows/lint.yaml)
[](https://github.com/cssnr/actions-tools/actions/workflows/release.yaml)
[](https://pypi.org/project/actions-tools/)
[](https://actions-tools.cssnr.com/)
[](https://github.com/cssnr/actions-tools/graphs/commit-activity)
[](https://github.com/cssnr/actions-tools)
[](https://github.com/cssnr/actions-tools?tab=readme-ov-file#readme)
[](https://github.com/cssnr/actions-tools/graphs/contributors)
[](https://github.com/cssnr/actions-tools/discussions)
[](https://github.com/cssnr/actions-tools/forks)
[](https://github.com/cssnr/actions-tools/stargazers)
[](https://cssnr.github.io/)
[](https://discord.gg/wXy6m2X8wY)
[](https://ko-fi.com/cssnr)
# Actions Tools
- [Install](#install)
- [Usage](#usage)
- [Support](#support)
- [Contributing](#contributing)
A Typed Python GitHub Actions Tookit similar to [actions/toolkit](https://github.com/actions/toolkit).
[](http://actions-tools.cssnr.com/)
> [!TIP]
> This project is in active development.
> Please let us know [what features](https://github.com/cssnr/actions-tools/issues/new?template=1-feature.yaml) you want to see.
From PyPI: https://pypi.org/p/actions-tools
```shell
pip install actions-tools
```
With [PyGithub](https://github.com/PyGithub/PyGithub) (for GitHub API access).
```shell
pip install actions-tools[github]
```
Add to your pyproject.toml.
```shell
pip install --group dev actions-tools
pip install --group dev actions-tools[github]
uv add --dev toml-run
uv add --dev toml-run[github]
```
Install from GitHub.
```shell
pip install git+https://github.com/cssnr/actions-tools.git
```
Install from source.
```shell
git clone https://github.com/cssnr/actions-tools
pip install actions-tools
```
Uninstall.
```shell
pip uninstall actions-tools
```
[](http://actions-tools.cssnr.com/usage/)
Functionality from @actions/toolkit
```python
from actions import core, context
# Input
my_str = core.get_input("string") # -> str
my_req = core.get_input("string", True) # required
my_bool = core.get_bool("boolean") # -> bool
my_list = core.get_list("list") # -> list
my_dict = core.get_dict("dict") # -> dict - from json or yaml
my_data = core.get_data("data") # -> Any - from json or yaml
# Context
# https://docs.github.com/en/actions/reference/workflows-and-actions/variables
core.info(f"event_name: {context.event_name}")
core.info(f"ref_name: {context.ref_name}")
core.info(f"runner_temp: {context.runner_temp}")
# Event
# https://docs.github.com/en/webhooks/webhook-events-and-payloads
event = core.get_event() # -> dict
core.info(str(event))
repository = event.get("repository")
# Logging
core.info("info") # alias for print
core.debug("debug")
# Annotations
# https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands#setting-a-notice-message
core.notice("notice")
core.warn("warn")
core.error("error", title="Title", file="File", col=1, endColumn=2, line=3, endLine=4)
# Blocks
core.start_group("Title")
core.info("This is folded.")
core.end_group()
with core.group("Title") as p:
p("This is folded.")
core.info("Also folded.")
# Environment
core.set_env("NAME", "value")
# State
name = core.set_state("name", "value")
value = core.get_state("name")
# System Path
core.add_path("/dev/null")
# Set Secret
core.mask("super-secret-string")
# Outputs
core.set_output("name", "cssnr")
# Commands
core.stop_commands()
core.info("::error::log output with commands")
core.start_commands()
# Abort
core.set_failed("Mayday!")
# Runner Debug
core.is_debug()
# PyGithub (Octokit)
# https://pygithub.readthedocs.io/en/stable/
token = core.get_input("token", True)
g = core.get_github(token)
repo = g.get_repo(context.repository)
core.info(f"repo.name: {repo.name}")
# OIDC Token
# https://docs.github.com/en/actions/reference/security/oidc
id_token = core.get_id_token()
# Summary
core.summary.add_raw("text")
# text\n
core.summary.add_eol()
# \n
core.summary.add_code("from actions import core", "python")
# \n
from actions import core
\n\n
core.summary.add_list(["item 1", "item 2"])
# \n- item 1 \n
- item 2
core.summary.add_details("Summary", "Details...")
# \nSummaryDetails...\n\n
core.summary.add_image("src", "alt", 100)
# \n
core.summary.add_heading("Heading", 1)
# \n
Heading
\n\ncore.summary.add_hr()
# \n
\n\n
core.summary.add_br()
# \n
\n\n
core.summary.add_quote("I broke it.", "ralf")
# \n
I broke it.\n\n
core.summary.add_link("text", "href")
# \ntext\n\n
# \ntext\n\n
core.summary.add_table([["Head 1", "Head 2"], ["data 1", "data 2"]])
# \nHead 1Head 2
# data 1data 2\n\n
with core.summary.with_code("text") as add:
add("line 1")
add("line 2")
# \n
line 1\nline 2\n\n
with core.summary.with_list() as add:
add("line 1")
add("line 2")
# \n
- \n
- line 1 \n
- line 2 \n
with core.summary.with_details("Summary") as add:
add("line 1")
add("line 2")
# \nSummary\n\nline 1\nline 2\n\n\n\n
```
- Full `core` reference: [../src/actions/core.py](https://github.com/cssnr/actions-tools/blob/master/src/actions/core.py)
- Full `context` reference: [../src/actions/context.py](https://github.com/cssnr/actions-tools/blob/master/src/actions/context.py)
Functionality new in actions-tools
```python
from actions import core, context
# Context
core.info(f"repository_name: {context.repository_name}")
# Commands
core.command("warning", "Warned!") # core.warn()
# Action Version
version = core.get_version() # from GITHUB_WORKFLOW_REF
# Random
rand = core.get_random(32)
# Indent
core.start_indent(4)
core.info("Indented") # only works with core.info
core.end_indent()
```
Example Actions.
- Create Files Action: [cssnr/create-files-action](https://github.com/cssnr/create-files-action)
- Python Action Template: [smashedr/test-action-py](https://github.com/smashedr/test-action-py)
- Python UV Action Template: [smashedr/test-action-uv](https://github.com/smashedr/test-action-uv)
[](http://actions-tools.cssnr.com/usage/)
If you run into any issues or need help getting started, please do one of the following:
- Report an Issue:
- Q&A Discussion:
- Request a Feature:
- Chat with us on Discord:
[](https://github.com/cssnr/actions-tools/issues/new?template=1-feature.yaml)
[](https://github.com/cssnr/actions-tools/issues)
[](https://github.com/cssnr/actions-tools/discussions)
[](https://discord.gg/wXy6m2X8wY)
If you would like to submit a PR, please review the [CONTRIBUTING.md](#contributing-ov-file).
Please consider making a donation to support the development of this project
and [additional](https://cssnr.com/) open source projects.
[](https://ko-fi.com/cssnr)
[](https://actions-tools.cssnr.com/)
Additionally, you can support other [GitHub Actions](https://actions.cssnr.com/) I have published:
- [Stack Deploy Action](https://github.com/cssnr/stack-deploy-action?tab=readme-ov-file#readme)
- [Portainer Stack Deploy Action](https://github.com/cssnr/portainer-stack-deploy-action?tab=readme-ov-file#readme)
- [Docker Context Action](https://github.com/cssnr/docker-context-action?tab=readme-ov-file#readme)
- [Actions Up Action](https://github.com/cssnr/actions-up-action?tab=readme-ov-file#readme)
- [Rhysd Actionlint Action](https://github.com/cssnr/actionlint-action?tab=readme-ov-file#readme)
- [Zensical Action](https://github.com/cssnr/zensical-action?tab=readme-ov-file#readme)
- [VirusTotal Action](https://github.com/cssnr/virustotal-action?tab=readme-ov-file#readme)
- [Mirror Repository Action](https://github.com/cssnr/mirror-repository-action?tab=readme-ov-file#readme)
- [Update Version Tags Action](https://github.com/cssnr/update-version-tags-action?tab=readme-ov-file#readme)
- [Docker Tags Action](https://github.com/cssnr/docker-tags-action?tab=readme-ov-file#readme)
- [TOML Action](https://github.com/cssnr/toml-action?tab=readme-ov-file#readme)
- [Update JSON Value Action](https://github.com/cssnr/update-json-value-action?tab=readme-ov-file#readme)
- [JSON Key Value Check Action](https://github.com/cssnr/json-key-value-check-action?tab=readme-ov-file#readme)
- [Parse Issue Form Action](https://github.com/cssnr/parse-issue-form-action?tab=readme-ov-file#readme)
- [Cloudflare Purge Cache Action](https://github.com/cssnr/cloudflare-purge-cache-action?tab=readme-ov-file#readme)
- [Mozilla Addon Update Action](https://github.com/cssnr/mozilla-addon-update-action?tab=readme-ov-file#readme)
- [Package Changelog Action](https://github.com/cssnr/package-changelog-action?tab=readme-ov-file#readme)
- [NPM Outdated Check Action](https://github.com/cssnr/npm-outdated-action?tab=readme-ov-file#readme)
- [Label Creator Action](https://github.com/cssnr/label-creator-action?tab=readme-ov-file#readme)
- [Algolia Crawler Action](https://github.com/cssnr/algolia-crawler-action?tab=readme-ov-file#readme)
- [Upload Release Action](https://github.com/cssnr/upload-release-action?tab=readme-ov-file#readme)
- [Check Build Action](https://github.com/cssnr/check-build-action?tab=readme-ov-file#readme)
- [Web Request Action](https://github.com/cssnr/web-request-action?tab=readme-ov-file#readme)
- [Get Commit Action](https://github.com/cssnr/get-commit-action?tab=readme-ov-file#readme)
❔ Unpublished Actions
These actions are not published on the Marketplace, but may be useful.
- [cssnr/create-files-action](https://github.com/cssnr/create-files-action?tab=readme-ov-file#readme) - Create various files from templates.
- [cssnr/draft-release-action](https://github.com/cssnr/draft-release-action?tab=readme-ov-file#readme) - Keep a draft release ready to publish.
- [cssnr/env-json-action](https://github.com/cssnr/env-json-action?tab=readme-ov-file#readme) - Convert env file to json or vice versa.
- [cssnr/push-artifacts-action](https://github.com/cssnr/push-artifacts-action?tab=readme-ov-file#readme) - Sync files to a remote host with rsync.
- [smashedr/update-release-notes-action](https://github.com/smashedr/update-release-notes-action?tab=readme-ov-file#readme) - Update release notes.
- [smashedr/combine-release-notes-action](https://github.com/smashedr/combine-release-notes-action?tab=readme-ov-file#readme) - Combine release notes.
---
📝 Template Actions
These are basic action templates that I use for creating new actions.
- [javascript-action](https://github.com/smashedr/javascript-action?tab=readme-ov-file#readme) - JavaScript
- [typescript-action](https://github.com/smashedr/typescript-action?tab=readme-ov-file#readme) - TypeScript
- [py-test-action](https://github.com/smashedr/py-test-action?tab=readme-ov-file#readme) - Dockerfile Python
- [test-action-uv](https://github.com/smashedr/test-action-uv?tab=readme-ov-file#readme) - Dockerfile Python UV
- [docker-test-action](https://github.com/smashedr/docker-test-action?tab=readme-ov-file#readme) - Docker Image Python
Note: The `docker-test-action` builds, runs and pushes images to [GitHub Container Registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry).
---
For a full list of current projects visit: [https://cssnr.github.io/](https://cssnr.github.io/)
