-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Daniel Rataj
committed
Nov 16, 2020
0 parents
commit d96a02a
Showing
8 changed files
with
1,282 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.env | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Create a container | ||
|
||
on: | ||
push: | ||
# Publish `v1.2.3` tags as releases. | ||
tags: | ||
- v* | ||
jobs: | ||
|
||
# Push image to GitHub Packages. | ||
# See also https://docs.docker.com/docker-hub/builds/ | ||
push: | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'push' | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Build image | ||
run: docker build . --file Dockerfile --tag image | ||
|
||
- name: Log into registry | ||
run: echo "${{ secrets.CR_PAT }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
|
||
- name: Push image | ||
run: | | ||
IMAGE_ID=ghcr.io/${{ github.repository }} | ||
# Strip git ref prefix from version | ||
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | ||
# Strip "v" prefix from tag name | ||
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') | ||
# keep only the major.minor release, no patch | ||
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/\.[0-9]*$//') | ||
echo IMAGE_ID=$IMAGE_ID | ||
echo VERSION=$VERSION | ||
docker tag image $IMAGE_ID:$VERSION | ||
docker push $IMAGE_ID:$VERSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.env | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
FROM node:14.13.0-alpine3.12 | ||
LABEL maintainer="Daniel Rataj <daniel.rataj@centrum.cz>" | ||
LABEL org.opencontainers.image.source="https://github.com/whoopsmonitor/whoopsmonitor-check-json-expect" | ||
LABEL com.whoopsmonitor.documentation="https://github.com/whoopsmonitor/whoopsmonitor-check-json-expect" | ||
LABEL com.whoopsmonitor.env.WM_API_ENDPOINT="https://" | ||
LABEL com.whoopsmonitor.env.WM_EXPECT="status/number/=/200" | ||
|
||
WORKDIR /app | ||
COPY ./src/index.js ./src/index.js | ||
COPY ./package.json ./package.json | ||
COPY ./package-lock.json ./package-lock.json | ||
|
||
RUN npm install | ||
|
||
CMD [ "npm", "start", "--silent" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# whoopsmonitor-check-json-expect | ||
|
||
Get remote JSON response and search for some specific results such as string, number. | ||
|
||
## Environmental variables | ||
|
||
- `WM_API_ENDPOINT` API endpoint to call. | ||
- `WM_EXPECT` Comma separated list of items. | ||
|
||
### WM_EXPECT | ||
|
||
It is separated into four parts separated with a slash. | ||
|
||
- `key` The name of the key to search in response. | ||
- `rule` | ||
- `string` | ||
- `number`, `integer` | ||
- `boolean` | ||
- `operator` | ||
- string | ||
- `eq`, `=` (exact match) | ||
- `*=` (partial match) | ||
- numbers | ||
- `eq`, `=` (exact match) | ||
- `gt`, `>` - greater than (numbers) | ||
- `lt`, `<` - lower than (numbers) | ||
- `value` Compared value. | ||
|
||
## Example | ||
|
||
There is an example of the check at Whoops Monitor configuration tab or the `.env` file. | ||
|
||
```yaml | ||
WM_API_ENDPOINT=https://localhost:1337 | ||
WM_EXPECT=data.db/boolean/=/true | ||
``` | ||
|
||
```yaml | ||
WM_API_ENDPOINT=https://localhost:1337 | ||
WM_EXPECT=data.db/number/gt/100 | ||
``` | ||
|
||
## Output | ||
|
||
- `0` - Data founded in the format as expected. | ||
- `2` - Data does not have a proper format. | ||
|
||
## Build | ||
|
||
```sh | ||
docker build -t whoopsmonitor-check-json-expect . | ||
``` | ||
|
||
## Run | ||
|
||
```bash | ||
docker run --rm --env-file .env whoopsmonitor-check-json-expect | ||
``` |
Oops, something went wrong.