2022-08-08 23:43:31 +02:00
|
|
|
A plugin to control GitHub workflows.
|
2022-08-08 12:16:00 +02:00
|
|
|
|
2022-08-08 12:24:26 +02:00
|
|
|
# Usage
|
|
|
|
|
2022-08-08 23:43:31 +02:00
|
|
|
The following settings change this plugin's behavior.
|
2022-08-08 12:24:26 +02:00
|
|
|
|
2022-08-08 23:43:31 +02:00
|
|
|
* github_token (required, **secret recommended**) GitHub authentication token.
|
|
|
|
* github_repo (required) the repo to act on.
|
|
|
|
* workflow_id (required) the workflow to act on, eg `workflow.yml`.
|
|
|
|
* workflow_actions (required) the actions to execute, one or more (separated by `,`) of:
|
|
|
|
* `start`: starts the workflow by creating a `workflow_dispatch` event
|
|
|
|
* `cancel`: cancels all queued and running workflows
|
|
|
|
* `delete`: deletes all completed workflow runs
|
2022-08-08 12:24:26 +02:00
|
|
|
|
|
|
|
Below is an example `.drone.yml` that uses this plugin.
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
kind: pipeline
|
|
|
|
name: default
|
|
|
|
|
|
|
|
steps:
|
2022-08-08 23:43:31 +02:00
|
|
|
- name: create workflow_dispatch event
|
2022-08-08 12:24:26 +02:00
|
|
|
image: itsblue.dev/plugins/github-workflow-controller
|
|
|
|
settings:
|
2022-08-08 23:43:31 +02:00
|
|
|
github_token:
|
|
|
|
from_secret: github-token
|
|
|
|
github_repo: "foo/bar"
|
|
|
|
workflow_id: "workflow.yml"
|
|
|
|
workflow_actions: start
|
2022-08-08 12:24:26 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
# Building
|
|
|
|
|
|
|
|
Build the plugin binary:
|
|
|
|
|
|
|
|
```text
|
|
|
|
scripts/build.sh
|
|
|
|
```
|
|
|
|
|
|
|
|
Build the plugin image:
|
|
|
|
|
|
|
|
```text
|
|
|
|
docker build -t itsblue.dev/plugins/github-workflow-controller -f docker/Dockerfile .
|
|
|
|
```
|
|
|
|
|
|
|
|
# Testing
|
|
|
|
|
|
|
|
Execute the plugin from your current working directory:
|
|
|
|
|
|
|
|
```text
|
|
|
|
docker run --rm -e PLUGIN_PARAM1=foo -e PLUGIN_PARAM2=bar \
|
2022-08-08 23:43:31 +02:00
|
|
|
-e PLUGIN_GITHUB_TOKEN=8f51ad7884c5eb69c11d260a31da7a745e6b78e2 \
|
|
|
|
-e PLUGIN_GITHUB_REPO=foo/bar \
|
|
|
|
-e PLUGIN_WORKFLOW_ID="workflow.yml" \
|
|
|
|
-e PLUGIN_WORKFLOW_ACTIONS="cancel,delete" \
|
2022-08-08 12:24:26 +02:00
|
|
|
itsblue.dev/plugins/github-workflow-controller
|
|
|
|
```
|