Skip to content

Commit

Permalink
Merge pull request #3 from lazybytez/feature/fix-lint-issues
Browse files Browse the repository at this point in the history
Fix linter issues
  • Loading branch information
pascal-zarrad authored Sep 24, 2023
2 parents 45e9709 + 488890d commit 48ba0e7
Show file tree
Hide file tree
Showing 8 changed files with 190 additions and 184 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ insert_final_newline = true
trim_trailing_whitespace = false

[*.yaml,*.yml]
indent_size = 2
indent_size = 4
91 changes: 46 additions & 45 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# In JavaScript actions, `dist/index.js` is a special file. When you reference
# an action with `uses:`, `dist/index.js` is the code that will be run. For this
# project, the `dist/index.js` file is generated from other source files through
Expand All @@ -10,57 +11,57 @@
name: Check dist/

on:
push:
branches:
- main
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
workflow_dispatch:
push:
branches:
- main
paths-ignore:
- "**.md"
pull_request:
paths-ignore:
- "**.md"
workflow_dispatch:

jobs:
check-dist:
name: Check dist/
runs-on: ubuntu-latest
check-dist:
name: Check dist/
runs-on: ubuntu-latest

permissions:
contents: read
statuses: write
permissions:
contents: read
statuses: write

steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 20
cache: npm
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 20
cache: npm

- name: Install Dependencies
id: install
run: npm ci
- name: Install Dependencies
id: install
run: npm ci

- name: Build dist/ Directory
id: build
run: npm run bundle
- name: Build dist/ Directory
id: build
run: npm run bundle

- name: Compare Expected and Actual Directories
id: diff
run: |
if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff --ignore-space-at-eol --text dist/
exit 1
fi
- name: Compare Expected and Actual Directories
id: diff
run: |
if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff --ignore-space-at-eol --text dist/
exit 1
fi
# If index.js was different than expected, upload the expected version as
# a workflow artifact.
- uses: actions/upload-artifact@v3
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with:
name: dist
path: dist/
# If index.js was different than expected, upload the expected version as
# a workflow artifact.
- uses: actions/upload-artifact@v3
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with:
name: dist
path: dist/
49 changes: 25 additions & 24 deletions .github/workflows/git.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
---
name: Git

on:
pull_request:
on:
pull_request:

jobs:
# Verify that the branch name matches the format
verify_branch_name:
runs-on: ubuntu-latest
steps:
- name: Check branch name
uses: deepakputhraya/action-branch-name@master
with:
regex: '([a-zA-Z0-0-])+\/([a-zA-Z0-0-])+'
allowed_prefixes: "feature,hotfix,release,renovate"
ignore: main,develop
# Verify that the branch name matches the format
verify_branch_name:
runs-on: ubuntu-latest
steps:
- name: Check branch name
uses: deepakputhraya/action-branch-name@master
with:
regex: '([a-zA-Z0-0-])+\/([a-zA-Z0-0-])+'
allowed_prefixes: "feature,hotfix,release,renovate"
ignore: main,develop

# Verify that the commits matches the format
verify_commit_messages:
if: (github.actor!= 'renovate[bot]') && (contains(github.head_ref, 'renovate/github_actions/') == false)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Run commitlint
uses: wagoid/commitlint-github-action@v2
with:
configFile: commitlint.config.js
# Verify that the commits matches the format
verify_commit_messages:
if: (github.actor!= 'renovate[bot]') && (contains(github.head_ref, 'renovate/github_actions/') == false)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Run commitlint
uses: wagoid/commitlint-github-action@v2
with:
configFile: commitlint.config.js
61 changes: 32 additions & 29 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,43 @@
---
# From: https://github.com/actions/javascript-action/blob/main/.github/workflows/linter.yml
name: Lint Code Base

on:
pull_request:
pull_request:

jobs:
lint:
name: Lint Code Base
runs-on: ubuntu-latest
lint:
name: Lint Code Base
runs-on: ubuntu-latest

permissions:
contents: read
packages: read
statuses: write
permissions:
contents: read
packages: read
statuses: write

steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4

- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v3
with:
node-version: 20
cache: npm
- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v3
with:
node-version: 20
cache: npm

- name: Install Dependencies
id: install
run: npm ci
- name: Install Dependencies
id: install
run: npm ci

- name: Lint Code Base
id: super-linter
uses: super-linter/super-linter/slim@v5
env:
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JAVASCRIPT_DEFAULT_STYLE: prettier
VALIDATE_JSCPD: false
- name: Lint Code Base
id: super-linter
uses: super-linter/super-linter/slim@v5
env:
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JAVASCRIPT_DEFAULT_STYLE: prettier
VALIDATE_JSCPD: false
FILTER_REGEX_EXCLUDE: "dist/.*"
VALIDATE_EDITORCONFIG: false
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
dist/
node_modules/
coverage/
coverage/
64 changes: 32 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,46 @@
[![gh-stars-badge][gh-stars-badge]][gh-stars]

## Description
This action allows to synchronize one or more markdown files to BookStack.
This action allows to synchronize one or more Markdown files to BookStack.
This makes it possible to maintain documentation within a repository while still
making it available in your central documentation solution.

This action features:
- Sync to either a chapter or a book
- Use either a single file or a glob pattern to sync multiple files
- Keep your pages up to date - the action can create and update pages
- Sync to either a chapter or a book
- Use either a single file or a glob pattern to sync multiple files
- Keep your pages up to date - the action can create and update pages

## Limitations
- To support globs and therefore the creation of multiple pages at once, this action uses the **first** headline of type **# (h1)** as the name for the pages
- Your markdown files **must** have at least one **#** to be accepted by the Action
- The sync is currently one way, so deleting files from the repo won't delete the pages from BookStack
- We always push an update to BookStack which generates additional traffic, however, BookStack won't create additional revisions if the content is unchanged
- You must grab the book/chapter id from the database or using the API to configure the action
- To support globs and therefore the creation of multiple pages at once, this action uses the **first** headline of type **# (h1)** as the name for the pages
- Your Markdown files **must** have at least one **#** to be accepted by the Action
- The sync is currently one way, so deleting files from the repository won't delete the pages from BookStack
- We always push an update to BookStack which generates additional traffic, however, BookStack won't create additional revisions if the content is unchanged
- You must grab the book/chapter ID from the database or using the API to configure the action

## Inputs

### `url`
- **Required**
- The URL to your BookStack instance, where the files will be synced to.
- **Required**
- The URL to your BookStack instance, where the files will be synced to.

### `token-id`
- **Required**
- The id of your BookStack API connection.
- **Required**
- The ID of your BookStack API connection.

### `token-secret`
- **Required**
- The secret of your BookStack API connection.
- **Required**
- The secret of your BookStack API connection.

### `book-id`
- **Required, when `chapter-id` is not set**
- The ID of the book to sync to.
- **Required, when `chapter-id` is not set**
- The ID of the book to sync to.

### `chapter-id`
- **Required, when `book-id` is not set**
- The ID of the book to sync to.
- **Required, when `book-id` is not set**
- The ID of the book to sync to.

### `path`
- The path to the markdown file(s) to sync, you can use glob patterns for multiple files
- The path to the Markdown file(s) to sync, you can use glob patterns for multiple files

## Outputs
This action does not output anything, if everything goes well.
Expand All @@ -54,22 +54,22 @@ This action does not output anything, if everything goes well.
```yaml
uses: lazybytez/[email protected]
with:
bookstack-url: 'https://bookstack.your.url'
bookstack-token-id: '{{ secrets.BOOKSTACK_TOKEN_ID }}'
bookstack-token-secret: '{{ secrets.BOOKSTACK_TOKEN_SECRET }}'
# You only need one of book-id or chapter-id
book-id: 123
chapter-id: 123
# You can either use a path to a file or a glob pattern:
path: 'sub/directories/README.md'
path: 'sub/*/*.md'
bookstack-url: 'https://bookstack.your.url'
bookstack-token-id: '{{ secrets.BOOKSTACK_TOKEN_ID }}'
bookstack-token-secret: '{{ secrets.BOOKSTACK_TOKEN_SECRET }}'
# You only need one of book-id or chapter-id
book-id: 123
chapter-id: 123
# You can either use a path to a file or a glob pattern:
path: 'sub/directories/README.md'
path: 'sub/*/*.md'
```
## Development
To develop locally, you should install **NodeJS 20**.
The following commands can be used for local development:
```
```shell
# Install dependencies
$ npm install

Expand All @@ -87,7 +87,7 @@ Be sure to always run the bundler and commit the `dist/` directory when doing ch

## Contributing

If you want to take part in contribution, like fixing issues and contributing directly to the code base, please visit
If you want to take part in contribution, like fixing issues and contributing directly to the codebase, please visit
the [How to Contribute][gh-contribute] document.

## Useful links
Expand All @@ -100,7 +100,7 @@ the [How to Contribute][gh-contribute] document.

<hr>

###### Copyright (c) [Lazy Bytez][gh-team]. All rights reserved | Licensed under the MIT license.
Copyright (c) [Lazy Bytez][gh-team]. All rights reserved | Licensed under the MIT license.

<!-- Variables -->

Expand Down
Loading

0 comments on commit 48ba0e7

Please sign in to comment.