Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/check-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: "Check Build"

on:
pull_request_target:
paths:
- "dist/**"
- "src/**"
- "package*.json"
- "rollup.config.*"

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

jobs:
check-build:
name: "Check Build"
runs-on: ubuntu-latest
timeout-minutes: 5

permissions:
pull-requests: write
issues: write

steps:
- name: "Debug CTX github"
continue-on-error: true
env:
GITHUB_CTX: ${{ toJSON(github) }}
run: echo "$GITHUB_CTX"

- name: "Checkout Pull"
uses: actions/checkout@v5
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: "Debug"
continue-on-error: true
run: |
echo "::group::ls"
ls -lAh
echo "::endgroup::"
echo "::group::tree"
tree .
echo "::endgroup::"

- name: "Check Build Action"
uses: cssnr/check-build-action@v1
9 changes: 3 additions & 6 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ concurrency:
jobs:
lint:
name: "Lint"
if: ${{ !contains(github.event.head_commit.message, '#nolint') }}
runs-on: ubuntu-latest
timeout-minutes: 5

Expand All @@ -24,7 +25,7 @@ jobs:
uses: actions/checkout@v5

- name: "Setup Node 24"
uses: actions/setup-node@v5
uses: actions/setup-node@v6
with:
node-version: 24

Expand Down Expand Up @@ -75,11 +76,7 @@ jobs:
run: |
yq -e '.runs.main | test("^dist/")' action.yml
- name: "Check Build Action"
if: ${{ !cancelled() }}
uses: cssnr/check-build-action@v1

- name: "ESLint Annotate"
if: ${{ !cancelled() && steps.eslint.outcome != 'success' }}
continue-on-error: true
uses: ataylorme/eslint-annotate-action@v3
uses: ataylorme/eslint-annotate-action@d57a1193d4c59cbfbf3f86c271f42612f9dbd9e9 # 3.0.0
29 changes: 27 additions & 2 deletions .github/workflows/pull.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: "Pull"

on:
pull_request:
pull_request_target:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -15,11 +15,36 @@ jobs:

permissions:
pull-requests: write
issues: write

steps:
- name: "Checkout"
- name: "Debug CTX github"
continue-on-error: true
env:
GITHUB_CTX: ${{ toJSON(github) }}
run: echo "$GITHUB_CTX"

- name: "Checkout Pull"
uses: actions/checkout@v5
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: "Debug"
continue-on-error: true
run: |
echo "::group::ls"
ls -lAh .
echo "::endgroup::"
echo "::group::tree"
tree .
echo "::endgroup::"
- name: "NPM Outdated Check"
continue-on-error: true
uses: cssnr/npm-outdated-action@master

- name: "Actions Up"
continue-on-error: true
uses: cssnr/actions-up-action@master
with:
exclude: "cssnr/.*,actions/.*"
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ jobs:

- name: "Send Failure Notification"
if: ${{ failure() }}
uses: sarisia/actions-status-discord@v1
uses: sarisia/actions-status-discord@11a0bfe3b50977e38aa2bd4a4ebd296415e83c19 # v1.15.4
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
7 changes: 7 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ jobs:
- name: "Checkout"
uses: actions/checkout@v4

- name: "Debug CTX github"
if: ${{ !github.event.act }}
continue-on-error: true
env:
GITHUB_CTX: ${{ toJSON(github) }}
run: echo "$GITHUB_CTX"

- name: "Test Local Action"
id: test
uses: ./
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ eslint_report.json
.env
.secrets
.vars
.github/workflows/local.yaml
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
[![GitHub Tag Minor](https://img.shields.io/github/v/tag/cssnr/json-key-value-check-action?sort=semver&filter=!v*.*.*&logo=git&logoColor=white&labelColor=585858&label=%20)](https://github.com/cssnr/json-key-value-check-action/releases)
[![GitHub Release Version](https://img.shields.io/github/v/release/cssnr/json-key-value-check-action?logo=git&logoColor=white&labelColor=585858&label=%20)](https://github.com/cssnr/json-key-value-check-action/releases/latest)
[![GitHub Dist Size](https://img.shields.io/github/size/cssnr/json-key-value-check-action/dist%2Findex.js?logo=bookstack&logoColor=white&label=dist%20size)](https://github.com/cssnr/json-key-value-check-action/blob/master/src/index.ts)
[![Action Run Using](https://img.shields.io/badge/dynamic/yaml?url=https%3A%2F%2Fraw.githubusercontent.com%2Fcssnr%2Fjson-key-value-check-action%2Frefs%2Fheads%2Fmaster%2Faction.yml&query=%24.runs.using&logo=githubactions&logoColor=white&label=runs)](https://github.com/cssnr/json-key-value-check-action/blob/master/action.yml)
[![Workflow Release](https://img.shields.io/github/actions/workflow/status/cssnr/json-key-value-check-action/release.yaml?logo=cachet&label=release)](https://github.com/cssnr/json-key-value-check-action/actions/workflows/release.yaml)
[![Workflow Test](https://img.shields.io/github/actions/workflow/status/cssnr/json-key-value-check-action/test.yaml?logo=cachet&label=test)](https://github.com/cssnr/json-key-value-check-action/actions/workflows/test.yaml)
[![Workflow Lint](https://img.shields.io/github/actions/workflow/status/cssnr/json-key-value-check-action/lint.yaml?logo=cachet&label=lint)](https://github.com/cssnr/json-key-value-check-action/actions/workflows/lint.yaml)
Expand Down Expand Up @@ -34,12 +35,12 @@ Check that JSON Key's Values Match Provided Values.

## Inputs

| input | required | default | description |
| --------- | :------: | ------- | ------------------------------ |
| file | **Yes** | - | JSON File Path to Validate |
| keys | **Yes** | - | Keys to Check, One per Line |
| values | **Yes** | - | Values to Verify, One per Line |
| seperator | - | `.` | Nested Key Seperator |
| Input | Default | Description of the Input |
| :-------- | :--------- | :-------------------------------------- |
| file | _Required_ | JSON File Path to Validate |
| keys | _Required_ | Keys to Check, One per Line |
| values | _Required_ | Values to Verify, One per Line |
| seperator | `.` | Nested Key Seperator |

For multiple `keys` and `values` use new lines with a yaml `|`.

Expand Down Expand Up @@ -117,18 +118,19 @@ For more information, see the CSSNR [SUPPORT.md](https://github.com/cssnr/.githu

# Contributing

If you would like to submit a PR, please review the [CONTRIBUTING.md](#contributing-ov-file).

Please consider making a donation to support the development of this project
and [additional](https://cssnr.com/) open source projects.

[![Ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/cssnr)

If you would like to submit a PR, please review the [CONTRIBUTING.md](#contributing-ov-file).

Additionally, you can support other GitHub Actions I have published:

- [Stack Deploy Action](https://github.com/cssnr/stack-deploy-action?tab=readme-ov-file#readme)
- [Portainer Stack Deploy Action](https://github.com/cssnr/portainer-stack-deploy-action?tab=readme-ov-file#readme)
- [Docker Context Action](https://github.com/cssnr/docker-context-action?tab=readme-ov-file#readme)
- [Actions Up Action](https://github.com/cssnr/actions-up-action?tab=readme-ov-file#readme)
- [VirusTotal Action](https://github.com/cssnr/virustotal-action?tab=readme-ov-file#readme)
- [Mirror Repository Action](https://github.com/cssnr/mirror-repository-action?tab=readme-ov-file#readme)
- [Update Version Tags Action](https://github.com/cssnr/update-version-tags-action?tab=readme-ov-file#readme)
Expand All @@ -151,6 +153,7 @@ Additionally, you can support other GitHub Actions I have published:

These actions are not published on the Marketplace, but may be useful.

- [cssnr/create-files-action](https://github.com/cssnr/create-files-action?tab=readme-ov-file#readme) - Create various files from templates.
- [cssnr/draft-release-action](https://github.com/cssnr/draft-release-action?tab=readme-ov-file#readme) - Keep a draft release ready to publish.
- [cssnr/env-json-action](https://github.com/cssnr/env-json-action?tab=readme-ov-file#readme) - Convert env file to json or vice versa.
- [cssnr/push-artifacts-action](https://github.com/cssnr/push-artifacts-action?tab=readme-ov-file#readme) - Sync files to a remote host with rsync.
Expand All @@ -166,9 +169,9 @@ These actions are not published on the Marketplace, but may be useful.
These are basic action templates that I use for creating new actions.

- [js-test-action](https://github.com/smashedr/js-test-action?tab=readme-ov-file#readme) - JavaScript
- [py-test-action](https://github.com/smashedr/py-test-action?tab=readme-ov-file#readme) - Python
- [ts-test-action](https://github.com/smashedr/ts-test-action?tab=readme-ov-file#readme) - TypeScript
- [docker-test-action](https://github.com/smashedr/docker-test-action?tab=readme-ov-file#readme) - Docker Image
- [py-test-action](https://github.com/smashedr/py-test-action?tab=readme-ov-file#readme) - Python (Dockerfile)
- [docker-test-action](https://github.com/smashedr/docker-test-action?tab=readme-ov-file#readme) - Docker (Image)

Note: The `docker-test-action` builds, runs and pushes images to [GitHub Container Registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry).

Expand Down
91 changes: 46 additions & 45 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as fs from 'node:fs';
import require$$0 from 'os';
import require$$0$1 from 'crypto';
import require$$1 from 'fs';
Expand Down Expand Up @@ -27,7 +28,6 @@ import require$$6 from 'string_decoder';
import require$$0$9 from 'diagnostics_channel';
import require$$2$2 from 'child_process';
import require$$6$1 from 'timers';
import * as fs from 'node:fs';

var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};

Expand Down Expand Up @@ -1719,7 +1719,7 @@ function requireTimers () {
return timers;
}

var main = {exports: {}};
var main$1 = {exports: {}};

var sbmh;
var hasRequiredSbmh;
Expand Down Expand Up @@ -3257,7 +3257,7 @@ function requireUrlencoded () {
var hasRequiredMain;

function requireMain () {
if (hasRequiredMain) return main.exports;
if (hasRequiredMain) return main$1.exports;
hasRequiredMain = 1;

const WritableStream = require$$0$7.Writable;
Expand Down Expand Up @@ -3338,12 +3338,12 @@ function requireMain () {
this._parser.write(chunk, cb);
};

main.exports = Busboy;
main.exports.default = Busboy;
main.exports.Busboy = Busboy;
main$1.exports = Busboy;
main$1.exports.default = Busboy;
main$1.exports.Busboy = Busboy;

main.exports.Dicer = Dicer;
return main.exports;
main$1.exports.Dicer = Dicer;
return main$1.exports;
}

var constants$3;
Expand Down Expand Up @@ -27247,43 +27247,44 @@ function requireCore () {

var coreExports = requireCore();

(async () => {
try {
const file = coreExports.getInput('file', { required: true });
console.log('file:', file);
const keys = coreExports.getInput('keys', { required: true }).split('\n');
console.log('keys:', keys);
const values = coreExports.getInput('values', { required: true }).split('\n');
console.log('values:', values);
const seperator = coreExports.getInput('seperator', {
required: true,
trimWhitespace: false,
});
console.log('seperator:', seperator);
if (keys.length !== values.length) {
return coreExports.setFailed('Keys and Values length are not equal.');
async function main() {
const file = coreExports.getInput('file', { required: true });
console.log('file:', file);
const keys = coreExports.getInput('keys', { required: true }).split('\n');
console.log('keys:', keys);
const values = coreExports.getInput('values', { required: true }).split('\n');
console.log('values:', values);
const seperator = coreExports.getInput('seperator', {
required: true,
trimWhitespace: false,
});
console.log('seperator:', seperator);
if (keys.length !== values.length) {
return coreExports.setFailed('Keys and Values length are not equal.');
}
const fileData = fs.readFileSync(file);
const data = JSON.parse(fileData.toString());
for (let i = 0; i < keys.length; i++) {
console.log(`--- ${i + 1}: ${keys[i]}: ${values[i]}`);
const key = keys[i].split(seperator);
console.log('key:', key);
const value = key.reduce((x, y) => x?.[y] ?? null, data);
console.log('value:', value);
if (values[i] == value) {
coreExports.info(`\u001b[32m"${values[i]}" == "${value}"`);
}
const fileData = fs.readFileSync(file);
const data = JSON.parse(fileData.toString());
for (let i = 0; i < keys.length; i++) {
console.log(`--- ${i + 1}: ${keys[i]}: ${values[i]}`);
const key = keys[i].split(seperator);
console.log('key:', key);
const value = key.reduce((x, y) => x?.[y] ?? null, data);
console.log('value:', value);
if (values[i] == value) {
coreExports.info(`\u001b[32m"${values[i]}" == "${value}"`);
}
else {
coreExports.info(`\u001b[31;1m"${values[i]}" != "${value}"`);
return coreExports.setFailed('One or more values were not equal.');
}
else {
coreExports.info(`\u001b[31;1m"${values[i]}" != "${value}"`);
return coreExports.setFailed('One or more values were not equal.');
}
coreExports.info(`\u001b[32;1mFinished Success`);
}
catch (e) {
console.log(e);
if (e instanceof Error)
coreExports.setFailed(e.message);
}
})();
coreExports.info(`\u001b[32;1mFinished Success`);
}
try {
await main();
}
catch (e) {
console.log(e);
if (e instanceof Error)
coreExports.setFailed(e.message);
}
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import typescriptEslint from '@typescript-eslint/eslint-plugin'
import tsParser from '@typescript-eslint/parser'
import { defineConfig } from 'eslint/config'

// noinspection JSCheckFunctionSignatures
export default defineConfig({
extends: [js.configs.recommended],
plugins: {
Expand Down
3 changes: 3 additions & 0 deletions event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"act": true
}
Loading