Skip to content

Commit

Permalink
feat: add github action functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
vanekj committed Feb 5, 2022
1 parent 041d6e7 commit 0be1ad4
Show file tree
Hide file tree
Showing 14 changed files with 2,465 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = tab
insert_final_newline = true
tab_width = 4
trim_trailing_whitespace = true

[*.yml]
indent_style = space
indent_size = 2
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Built resources
.dist

# Dependency directories
node_modules
12 changes: 12 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"root": true,
"env": {
"es2021": true,
"node": true
},
"extends": ["eslint:recommended", "prettier"],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
}
}
37 changes: 37 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build

on:
workflow_dispatch:
push:
paths:
- 'src/action.js'
- 'action.yml'
- 'package.json'
- 'package-lock.json'

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup node
uses: actions/setup-node@v2
with:
node-version: '16'

- name: Install dependencies
run: npm ci

- name: Build application
run: npm run build

- name: Update resources
uses: test-room-7/action-update-file@v1
with:
file-path: .dist/*
commit-msg: 'feat(dist): update resources'
github-token: ${{ secrets.GITHUB_TOKEN }}
allow-removing: true
26 changes: 26 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Lint

on:
workflow_dispatch:
push:
paths:
- '!.dist/**'

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup node
uses: actions/setup-node@v2
with:
node-version: '16'

- name: Install dependencies
run: npm ci

- name: Run ESLint
run: npm run lint
70 changes: 70 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# parcel-bundler cache (https://parceljs.org/)
.cache

# Serverless directories
.serverless

# IDE
.idea

# OS generated
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
17 changes: 17 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"semi": true,
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100,
"useTabs": true,
"tabWidth": 4,
"overrides": [
{
"files": ["*.yml"],
"options": {
"useTabs": false,
"tabWidth": 2
}
}
]
}
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"EditorConfig.EditorConfig"
]
}
10 changes: 10 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Validate JSON(s) GitHub Action

Validate JSON(s) by given schema using Ajv schema validator.

## Why another JSON validation action you ask..

I was facing issues with the other actions for JSON validations and so I made my own. If you are facing issues like the one below, I recommend to switch to this one.

```
no schema with key or ref "https://json-schema.org/draft-07/schema"
```

## Inputs

### `schema`

**Required** Relative path to the JSON schema file

### `pattern`

**Required** Glob pattern to the JSON(s) to validate

## Outputs

List of all processed files and it's validation result.

## Example usage

```yml
uses: vanekj/validate-json-action@v1
with:
schema: schemas/default.schema.json
pattern: data/**/*.json
```
19 changes: 19 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 'Ajv validate JSON(s)'
description: 'Validate JSON(s) by given schema using Ajv schema validator'
author: 'vanekj'
inputs:
schema:
description: 'Relative path to the JSON schema file (eg. schemas/default.schema.json)'
required: true
pattern:
description: 'Glob pattern to the JSON(s) to validate (eg. data/**/*.json)'
required: true
outputs:
result:
description: 'Relative paths to the invalid JSON(s)'
runs:
using: 'node16'
main: '.dist/index.js'
branding:
icon: 'search'
color: 'green'
Loading

0 comments on commit 0be1ad4

Please sign in to comment.