Skip to content

Commit

Permalink
Merge pull request #2 from lazybytez/feature/implement-action
Browse files Browse the repository at this point in the history
Implement the Action
  • Loading branch information
pascal-zarrad authored Sep 24, 2023
2 parents 542078d + 5f76d06 commit 45e9709
Show file tree
Hide file tree
Showing 10 changed files with 19,167 additions and 20 deletions.
89 changes: 80 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,37 @@
# Sync Markdown to BookStack Action

[![gh-commit-badge][gh-commit-badge]][gh-commit]
[![gh-contributors-badge][gh-contributors-badge]][gh-contributors]
[![gh-stars-badge][gh-stars-badge]][gh-stars]

## Description
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
- Add tags to the generated pages
- 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

## Inputs

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

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

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

Expand All @@ -31,9 +43,6 @@ This action features:
- **Required, when `book-id` is not set**
- The ID of the book to sync to.

### `tags`
- The tags to add to the page, comma separated

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

Expand All @@ -51,8 +60,70 @@ with:
# You only need one of book-id or chapter-id
book-id: 123
chapter-id: 123
tags: 'action,sync,bookstack'
# 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:
```
# Install dependencies
$ npm install

# Format and bundle for distribution
$ npm run bundle

# Only check code style using prettier
$ npm run format:check

# Check code style and reformat
$ npm run format:write
```

Be sure to always run the bundler and commit the `dist/` directory when doing changes to the code.

## Contributing

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

## Useful links

[License][gh-license] -
[Contributing][gh-contribute] -
[Code of conduct][gh-codeofconduct] -
[Issues][gh-issues] -
[Pull requests][gh-pulls]

<hr>

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

<!-- Variables -->

[gh-commit-badge]: https://img.shields.io/github/last-commit/lazybytez/sync-markdown-bookstack-action?style=for-the-badge&colorA=302D41&colorB=cba6f7

[gh-commit]: https://github.com/lazybytez/sync-markdown-bookstack-action/commits/main

[gh-contributors-badge]: https://img.shields.io/github/contributors/lazybytez/sync-markdown-bookstack-action?style=for-the-badge&colorA=302D41&colorB=89dceb

[gh-contributors]: https://github.com/lazybytez/sync-markdown-bookstack-action/graphs/contributors

[gh-stars-badge]: https://img.shields.io/github/stars/lazybytez/sync-markdown-bookstack-action?style=for-the-badge&colorA=302D41&colorB=f9e2af

[gh-stars]: https://github.com/lazybytez/sync-markdown-bookstack-action/stargazers

[gh-contribute]: https://github.com/lazybytez/.github/blob/main/docs/CONTRIBUTING.md

[gh-license]: https://github.com/lazybytez/sync-markdown-bookstack-action/blob/main/LICENSE

[gh-codeofconduct]: https://github.com/lazybytez/.github/blob/main/docs/CODE_OF_CONDUCT.md

[gh-issues]: https://github.com/lazybytez/sync-markdown-bookstack-action/issues

[gh-pulls]: https://github.com/lazybytez/sync-markdown-bookstack-action/pulls

[gh-team]: https://github.com/lazybytez
13 changes: 5 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
name: 'Sync Markdown to BookStack'
description: 'An action that syncs markdown files to a book or chapter in BookStack'
inputs:
bookstack-url:
url:
description: 'The URL of the BookStack instance'
required: true
bookstack-token-id:
token-id:
description: 'The id of your BookStack API connection'
required: true
bookstack-token-secret:
token-secret:
description: 'The secret of your BookStack API connection'
required: true
# One of these two must be passed - checked in JS code
book-id:
book-id:
description: 'The ID of the book to sync to'
required: false
chapter-id:
description: 'The ID of the chapter to sync to'
required: false
tags:
description: 'The tags to add to the page, comma separated'
required: false
path:
description: 'The path to the markdown file(s) to sync, you can use glob patterns for multiple files'
required: true

runs:
using: 'node20'
main: 'dist/index.js'
main: 'dist/index.js'
Loading

0 comments on commit 45e9709

Please sign in to comment.