Skip to content

Commit

Permalink
feat: dynamic required input validation (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
danadajian authored Jan 19, 2022
1 parent 989e4b3 commit 4180130
Show file tree
Hide file tree
Showing 61 changed files with 267 additions and 127 deletions.
72 changes: 36 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,42 @@
# github-helpers
#### A collection of Github Actions that simplify and standardize common CI/CD workflow tasks.

## Helpers:
## Usage
### General
```yaml
uses: ExpediaGroup/github-helpers@v1
with:
helper: < HELPER NAME >
...
github_token: ${{ secrets.GITHUB_TOKEN }}
```
The `helper` and `github_token` inputs are required for all helpers. Additional inputs vary by helper. Each helper file in `src/helpers` contains an interface that defines which additional inputs are required or optional. If a required input is ommitted, the helper will throw a descriptive error.

### Example
Input interface in `src/helpers/set-commit-status.ts`:
```ts
export class SetCommitStatus {
sha = ''; // required
context = ''; // required
state = ''; // required
description?: string; // optional
target_url?: string; // optional
}
```
Github Actions workflow invocation:
```yaml
uses: ExpediaGroup/github-helpers@v1
with:
helper: set-commit-status
sha: ${{ github.event.pull_request.head.sha }}
context: My Context
state: success
description: My Description
github_token: ${{ secrets.GITHUB_TOKEN }}
```

## Available Helpers
Each of the following helpers are defined in a file of the same name in `src/helpers`:

### [**add-labels**](.github/workflows/add-labels.yml)
Expand Down Expand Up @@ -77,41 +112,6 @@ Additionally, the following parameters can be used for additional control over t
### [**set-latest-pipeline-status**](.github/workflows/set-latest-pipeline-status.yml)
* Determines whether the pipeline is clear for a PR. This means it will set the "pipeline" commit status to `pending` if there is an in-progress production deployment for the repo, and `success` otherwise.

## Usage
### General
```yaml
uses: ExpediaGroup/github-helpers@v1
with:
helper: < HELPER NAME >
...
github_token: ${{ secrets.GITHUB_TOKEN }}
```
The `helper` and `github_token` inputs are required for all helpers. Additional inputs vary by helper. Each helper file in `src/helpers` contains an interface that defines which additional inputs are required or optional.

### Example
Input interface in `src/helpers/set-commit-status.ts`:
```ts
interface SetCommitStatus {
sha: string;
context: string;
state: PipelineState;
description?: string;
target_url?: string;
}
```
Github Actions workflow invocation:
```yaml
uses: ExpediaGroup/github-helpers@v1
with:
helper: set-commit-status
sha: ${{ github.event.pull_request.head.sha }}
context: My Context
state: success
description: My Description
github_token: ${{ secrets.GITHUB_TOKEN }}
```

## Legal

This project is available under the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0.html).
Expand Down
6 changes: 6 additions & 0 deletions dist/0.index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/0.index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions dist/101.index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4180130

Please sign in to comment.