Skip to content

Commit

Permalink
Change: Update documentation for actions
Browse files Browse the repository at this point in the history
Update and improve README for documenting the actions.
  • Loading branch information
bjoernricks committed May 12, 2023
1 parent 568f346 commit a907c74
Show file tree
Hide file tree
Showing 18 changed files with 437 additions and 144 deletions.
106 changes: 23 additions & 83 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,18 @@

Repository that contains a collection of GitHub Actions for Greenbone projects

## Language specific CI actions
## Language specific Actions

We offer several actions for linting, formatting, building and testing packages/modules/projects in different programming languages

### Python

```yml
- name: Install python and poetry and the project
uses: greenbone/actions/poetry@v2
with:
version: 3.9

- name: Install python, poetry, project and run coverage
uses: greenbone/actions/coverage-python@v2
with:
version: 3.9

- name: Install python, poetry, project and run lint
uses: greenbone/actions/lint-python@v2
with:
version: 3.9
```
* [Install python, poetry and the project](https://github.com/greenbone/actions/tree/v2/poetry)
* [Install python, poetry, project and run coverage to create a code coverage report](https://github.com/greenbone/actions/tree/v2/coverage-python)
* [Install python, poetry, project and run pylint linter](https://github.com/greenbone/actions/tree/v2/lint-python)
* [Install python, poetry, project and and run mypy type checker](https://github.com/greenbone/actions/tree/v2/mypy-python)
* [Install python, poetry, build python package and upload it to PyPI](https://github.com/greenbone/actions/tree/v2/pypi-upload)
* [Setup python and pontos](https://github.com/greenbone/actions/tree/v2/setup-pontos)

### JavaScript

Expand Down Expand Up @@ -67,58 +57,24 @@ We offer several actions for linting, formatting, building and testing packages/
uses: greenbone/actions/doc-coverage-clang@v2
```
## Branch protection
```yml
- name: lock <target> branch on <repository>
uses: greenbone/actions/lock-branch@v2
with:
lock: "true"
github-token: ${{ token }}
branch: <target>
repository: <repository>
- name: unlock <target> branch on <repository>
uses: greenbone/actions/lock-branch@v2
with:
lock: "false"
github-token: ${{ token }}
branch: <target>
repository: <repository>
- name: allow admin users bypassing protection on <target> branch on <repository>
uses: greenbone/actions/admin-bypass@v2
with:
allow: "true"
github-token: ${{ token }}
branch: <target>
repository: <repository>
- name: disable bypassing protection on <target> branch on <repository> for admin users
uses: greenbone/actions/admin-bypass@v2
with:
allow: "false"
github-token: ${{ token }}
branch: <target>
repository: <repository>
```
## Language independent Actions
### Branch protection
## Other useful actions
* [Lock and unlock a branch in a GitHub repository](https://github.com/greenbone/actions/tree/v2/lock-branch)
* [Allow and disallow admin users bypassing protection rules](https://github.com/greenbone/actions/tree/v2/admin-bypass)
Release a project in C, GoLang, JavaScript or Python
### Other useful actions
```yml
- name: Run release actions
uses: greenbone/actions/release@v2
with:
github-user: ${{ secrets.FOO_BAR }}
github-user-mail: foo@bar.baz
github-user-token: bar
gpg-key: boo
gpg-passphrase: foo
gpg-fingerprint: baz
release-type: calendar
ref: main
```
* [Release a project in C, GoLang, JavaScript or Python](https://github.com/greenbone/actions/tree/v2/release)
* [Create and upload signatures for GitHub release files](https://github.com/greenbone/actions/tree/v2/sign-release-files)
* [Report usage of conventional commits in a Pull Request](https://github.com/greenbone/actions/tree/v2/conventional-commits)
* [Check for consistent versioning in a project](https://github.com/greenbone/actions/tree/v2/check-version)
* [Backport Pull Requests to other additional branches](https://github.com/greenbone/actions/tree/v2/backport-pull-request)
* [Workflow notifications in Mattermost channels](https://github.com/greenbone/actions/tree/v2/mattermost-notify)
* [Trigger Workflow Runs](https://github.com/greenbone/actions/tree/v2/trigger-workflow)
* [Download Workflow Artifacts from a different workflow or even repository](https://github.com/greenbone/actions/tree/v2/trigger-workflow)
Update licence header supporting many different filetypes
Update license header supporting many different filetypes
```yml
- name: Run update header
Expand Down Expand Up @@ -148,25 +104,9 @@ SHA256 file or GPG signature generation
file: ./foo/bar
```
Check for consistent versioning in a project
```yml
- name: Check versioning
uses: greenbone/actions/check-version@v2
```
Report Conventional Commits
```yml
- name: Check conventional commits
uses: greenbone/actions/conventional-commits@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
```
## Support
For any question on the usage of python-gvm please use the
For any question on the usage of the Greenbone actions please use the
[Greenbone Community Forum](https://forum.greenbone.net/). If you
found a problem with the software, please
[create an issue](https://github.com/greenbone/actions/issues)
Expand All @@ -178,6 +118,6 @@ This project is maintained by [Greenbone AG](https://www.greenbone.net/).
## License
Copyright (C) 2020-2022 [Greenbone AG](https://www.greenbone.net/)
Copyright (C) 2020-2023 [Greenbone AG](https://www.greenbone.net/)
Licensed under the [GNU General Public License v3.0 or later](LICENSE).
40 changes: 40 additions & 0 deletions admin-bypass/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Admin bypass Action

GitHub Action that allows or disallows repository admins to bypass branch
protection rules.

## Examples

```yml
name: Bypass Branch Protection

on:
push:

jobs:
lock:
name: Bypass Protection
runs-on: ubuntu-latest
steps:
- name: allow admin users bypassing protection on <target> branch on <repository>
uses: greenbone/actions/admin-bypass@v2
with:
allow: "true"
branch: <target>
repository: <repository>
- name: disable bypassing protection on <target> branch on <repository> for admin users
uses: greenbone/actions/admin-bypass@v2
with:
allow: "false"
branch: <target>
repository: <repository>
```
## Action Configuration
|Input Variable|Description| |
|--------------|-----------|-|
| github-token | Github user token, that is legitimated to bypass branch protection. | Optional (default: `${{ github.token }}`) |
| allow | Allow or not? (Options: `"true"`, `"false"`)? | Optional (default is `"false"`) |
| repository | What repository branch should be able to be bypassed by admins? Defaults to the executing repository. | Optional (default is `${{ github.repository }}` |
| branch | Target branch for the bypass. | Optional (default is `"main"`) |
2 changes: 2 additions & 0 deletions backport-pull-request/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

GitHub Action to backport pull requests.

## Examples

To run this action you need to add the following code to your workflow file
(for example `.github/workflows/backport.yml`):

Expand Down
27 changes: 27 additions & 0 deletions check-version/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Check Version

GitHub Action to check version information of a project via pontos

## Example

```yml
name: Check Versioning

on:
push:
pull_request:

jobs:
check:
name: Check Versioning
runs-on: ubuntu-latest
steps:
- uses: greenbone/actions/check-version@v2
```
## Action Configuration
|Input Variable|Description| |
|--------------|-----------|-|
| python-version | Python version to use for running the action. | Optional (default is `3.10`) |
| working-directory | "A working directory where to check the versioning | Optional (default is `${{ github.workspace }}`) |
29 changes: 23 additions & 6 deletions conventional-commits/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

GitHub Action to check for conventional commits

To run this action you need to add the following code to your workflow file
(for example `.github/workflows/backport.yml`):
## Examples

```yml
name: Conventional Commits
Expand All @@ -22,15 +21,33 @@ jobs:
steps:
- name: Report Conventional Commits
uses: greenbone/actions/conventional-commits@v2
with:
token: ${{ secrets.SOME_TOKEN }}
```
```yml
name: Conventional Commits ignore users foo and bar

on:
pull_request:

permissions:
pull-requests: write
contents: read

jobs:
conventional-commits:
if: (!contains(split('foo,bar', ','), github.actor))
name: Report Conventional Commits
runs-on: ubuntu-latest
steps:
- name: Report Conventional Commits
uses: greenbone/actions/conventional-commits@v2
```
## 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)) |
| 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`) |
| cache-poetry-installation | Cache poetry and its dependencies. | Optional (default is `"true"`) |
36 changes: 36 additions & 0 deletions coverage-python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Python Coverage Report

Action to setup Python, poetry, the project itself and afterwards to create a
test coverage report.

## Example

```yaml
name: Code Coverage

on:
release:
types: [created]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Create Coverage Report
uses: greenbone/actions/coverage-python@v2
```
## Action Configuration
| Input | Description | |
|-------|-------------|-|
| python-version | Python version that should be installed | Optional (default: "3.10") |
| test-command | Command to run the unit tests | Optional (default: `"-m unittest"`)
| poetry-version | Use a specific poetry version. By default the latest release is used. | Optional |
| cache | Cache dependencies by setting it to `"true"`. Leave unset or set to an other string then `"true"` to disable the cache. | Optional |
| cache-dependency-path | "Used to specify the path to dependency files. Supports wildcards or a list of file names for caching multiple dependencies. | Optional |
| cache-poetry-installation | Cache poetry and its dependencies. Default is `"true"`. Set to an other string then `"true"` to disable the cache. | Optional (default is `"true"`) |
| install-dependencies | Install project dependencies. Default is `"true"`. Set to an other string then `"true"` to not install the dependencies. | Optional (default: `"true"`) |
| working-directory | Working directory where to run the action | Optional (default is `${{ github.workspace }}`) |
| codecov-upload | "Upload coverage to codecov.io. Default is `"true"`. Set to an other string then `"true"` to disable the upload. | Optional (default: `"true"`)
| token | Upload token for codecov.io. | Required only if codecov-upload is `"true"` |
34 changes: 18 additions & 16 deletions download-artifact/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ workflow runs with an event of `schedule` and `workflow_dispatch` are
considered. The action loads workflow runs with these events and downloads the
artifact(s) from the newest run.

## Example

To use this action you need to add the following code to your workflow file
(for example `.github/workflows/artifacts.yml`):

Expand Down Expand Up @@ -46,18 +48,18 @@ jobs:
## Action Configuration
| Input Variable | Description | |
| --------------- | ------------------------------------------------------------------------------------------ | ------------------------------------------------- |
| token | Token required to create the backport pull request | Required |
| workflow | Workflow to trigger. Either a workflow ID or file name, for example `ci.yml`. | Required |
| workflow-events | Consider only workflow runs triggered by the specified events. | Default: `schedule, workflow_dispatch` |
| repository | Repository of the workflow to trigger | Default: `GITHUB_REPOSITORY` (current repository) |
| branch | The git branch for the workflow. | Default: `main` |
| path | Destination path for the to be downloaded artifact of parent directory if name is not set. | Default: `.` (Current directory) |
| name | Name of the artifact to be downloaded. If not set all artifacts will be downloaded. | Optional |
| allow-not-found | Set to `true` to not fail if workflow or artifact can not be found. | Optional |
| user | User ID for ownership of the downloaded artifacts. | Optional |
| group | Group ID for ownership of the downloaded artifacts. | Optional |
| Input Variable | Description | |
| --------------- | ----------- |-|
| token | Token required to create the backport pull request | Required |
| workflow | Workflow to trigger. Either a workflow ID or file name, for example `"ci.yml"`. | Required |
| workflow-events | Consider only workflow runs triggered by the specified events. | Optional (default is `"schedule, workflow_dispatch"`) |
| repository | Repository of the workflow to trigger | Optional (default is `${{ github.repository }}` (current repository)) |
| branch | The git branch for the workflow. | Optional (default is `"main"`) |
| path | Destination path for the to be downloaded artifact of parent directory if name is not set. | Optional (default is `.` (Current directory)) |
| name | Name of the artifact to be downloaded. If not set all artifacts will be downloaded. | Optional |
| allow-not-found | Set to `"true"` to not fail if workflow or artifact can not be found. | Optional |
| user | User ID for ownership of the downloaded artifacts. | Optional |
| group | Group ID for ownership of the downloaded artifacts. | Optional |

The name input parameter mimics the [actions/download-artifact@v3](https://github.com/actions/download-artifact/tree/v3#download-all-artifacts)
behavior:
Expand Down Expand Up @@ -85,7 +87,7 @@ parameter is `tmp`, the directory structure will look like this:
... contents of artifact-a
```

| Output Variable | Description |
| -------------------------- | ------------------------------------------------------ |
| downloaded-artifacts | List of downloaded artifact names as JSON array string |
| total-downloaded-artifacts | Number of downloaded artifacts |
| Output Variable | Description |
| ----------------| ------------|
| downloaded-artifacts | List of downloaded artifact names as JSON array string |
| total-downloaded-artifacts | Number of downloaded artifacts |
35 changes: 35 additions & 0 deletions lint-python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Lint Python Action

GitHub Action to setup a Python project and lint it via pylint

## Example

```yml
name: Linting

on:
pull_request:

jobs:
lint-python:
name: Setup Python and lint project
runs-on: ubuntu-latest
steps:
- uses: greenbone/actions/lint-python@v2
with:
packages: my_project tests
```
## Action Configuration
|Input Variable|Description| |
|--------------|-----------|-|
| packages | Python packages to lint | Required |
| python-version | Python version to use for running the action. | Optional (default is `3.10`) |
| poetry-version | Use a specific poetry version. By default the latest release is used. | Optional (default latest poetry version) |
| cache | Cache dependencies by setting it to `"true"`. Leave unset or set to an other string then `"true"` to disable the cache. | Optional |
| cache-dependency-path | Used to specify the path to dependency files. Supports wildcards or a list of file names for caching multiple dependencies. | Optional |
| cache-poetry-installation | "Cache poetry and its dependencies. Default is `"true"`. Set to an other string then `"true"` to disable the cache." | Optional (default: `"true"`) |
| install-dependencies | Install project dependencies. Default is `"true"`. Set to an other string then `"true"` to not install the dependencies. | Optional (default: `"true"`)
| working-directory | Working directory where to run the action | Optional (default is `${{ github.workspace }}`) |

Loading

0 comments on commit a907c74

Please sign in to comment.