Skip to content

Commit

Permalink
Add validate-inputs action
Browse files Browse the repository at this point in the history
  • Loading branch information
mikogs committed Oct 31, 2023
1 parent 0c24e6c commit c6e0ef6
Show file tree
Hide file tree
Showing 7 changed files with 30,582 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/_test-validate-inputs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
name: Test validate-inputs action sub-workflow

on:
workflow_call:
inputs:
number:
description: A number
required: true
type: string
alphanumeric-string:
description: An alphanumeric string
required: true
type: string
fruit:
description: A fruit
required: true
type: string

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

jobs:
main:
name: Test validate-inputs action
runs-on: ubuntu-20.04
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Validate inputs
uses: ./validate-inputs
with:
names: |-
number
alphanumeric-string
fruit
regexps: |-
[0-9]+
[a-z0-9]+
apple|banana|lichi
46 changes: 46 additions & 0 deletions .github/workflows/test-validate-inputs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
name: Test validate-inputs action

on:
pull_request:
branches:
- main
push:
branches:
- main

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

jobs:
main:
name: Test validate-inputs action
runs-on: ubuntu-20.04
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Call sub-workflow with valid inputs
uses: ./.github/workflows/_test-validate-inputs.yml
with:
number: 44
alphanumeric: abc123
fruit: lichi

- name: Call sub-workflow with invalid inputs
uses: ./.github/workflows/_test-validate-inputs.yml
id: should-fail
continue-on-error: true
with:
number: a
alphanumeric: 34-a
fruit: lemon

- name: Check failure
shell: bash
run: |
if [[ "${{ steps.should-fail.outcome }}" == "success" ]]; then
echo "!!! Failure test failed. Something fishy is going on here"
exit 1
fi
13 changes: 13 additions & 0 deletions validate-inputs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
name: Validate inputs
description: This action validates inputs
inputs:
names:
description: Names of inputs to be checked against regular expression. One per line
required: true
regexps:
description: Regular expressions to check against. One per line
required: true
runs:
using: 'node20'
main: 'dist/index.js'
Loading

0 comments on commit c6e0ef6

Please sign in to comment.