Skip to content

Commit

Permalink
Initial commit of project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
egmacke committed Oct 28, 2021
1 parent da8c86b commit 30fdb81
Show file tree
Hide file tree
Showing 11 changed files with 11,657 additions and 1 deletion.
46 changes: 46 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Test steps

on:
pull_request:

env:
LABEL: testing
MISSING_LABEL: missing

jobs:
test:
name: Test Action
runs-on: ubuntu-latest
steps:
- name: Add test label
uses: actions-ecosystem/[email protected]
with:
labels: ${{ env.LABEL }}
github_token: ${{ github.token }}

- name: Check for present label
uses: egmacke/action-check-label@v1
with:
label: ${{ env.LABEL }}
state: 'present'

- name: Check for absent label
uses: egmacke/action-check-label@v1
with:
label: ${{ env.MISSING_LABEL }}
state: 'absent'

- name: Check for absent label that is present, but don't fail
uses: egmacke/action-check-label@v1
with:
label: ${{ env.LABEL }}
state: 'absent'
fail_on_error: false

- name: Check for absent label that is present, and fail
uses: egmacke/action-check-label@v1
continue-on-error: true
with:
label: ${{ env.LABEL }}
state: 'absent'

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,34 @@
# action-check-label
Check a PR for the presence or absence of a label

Github Action to check for presence or absence of a PR/issue label

## Inputs

| Name | Description | Type | Required | Default |
| --------------- | ------------------------------------------------------- | --------- | -------- | -------------------------- |
| `label` | The label to test for | `string` | `true` | `N/A` |
| `state` | The state of the label [`present`, `absent`] | `string` | `false` | `present` |
| `github_token` | A github token | `string` | `false` | `${{github.token}}` |
| `repo` | The owner and repository name | `string` | `false` | `${{ github.repository }}` |
| `fail_on_error` | Whether to fail the workflow if the state doesn't match | `boolean` | `false` | `true` |

## Output

| Name | Description |
| ----- | -------------------------------------------------------------- |
| state | The actual state of the label [`present`, `absent`] |
| pass | Whether the state matched the expected state [`true`, `false`] |

# Example use

For a simple check that a label exists on the current PR:

```yml
steps:
- name: Check for present label
uses: egmacke/action-check-label@v1
with:
label: test
```
For more examples, see `.github/workflows/test.yml`
32 changes: 32 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: action-check-label
author: egmacke
description: Check for the presence or absence of a label on a PR
inputs:
label:
description: The label to test for
required: true
state:
description: The state of the label
required: false
default: 'present'
github_token:
description: A github token
required: false
default: ${{ github.token }}
repo:
description: The owner and repository name
required: false
default: ${{ github.repository }}
fail_on_error:
description: Whether to fail the workflow if the state doesn't match
required: false
default: 'true'

runs:
using: node12
main: dist/index.js

branding:
color: purple
icon: bookmark

Loading

0 comments on commit 30fdb81

Please sign in to comment.