Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize action repository #1

Merged
merged 9 commits into from
Sep 24, 2023
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
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 4

end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[*.yaml,*.yml]
indent_size = 2
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/** -diff linguist-generated=true
66 changes: 66 additions & 0 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# 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
# the build process. We need to make sure that the checked-in `dist/index.js`
# file matches what is expected from the build.
#
# This workflow will fail if the checked-in `dist/index.js` file does not match
# what is expected from the build.
# From: https://github.com/actions/javascript-action/blob/main/.github/workflows/check-dist.yml
name: Check dist/

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

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

permissions:
contents: read
statuses: write

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: Install Dependencies
id: install
run: npm ci

- 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

# 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/
29 changes: 29 additions & 0 deletions .github/workflows/git.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Git

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 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
40 changes: 40 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# From: https://github.com/actions/javascript-action/blob/main/.github/workflows/linter.yml
name: Lint Code Base

on:
pull_request:

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

permissions:
contents: read
packages: read
statuses: write

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: 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
142 changes: 142 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# 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
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

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

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

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

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/
node_modules/
coverage/
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Sync Markdown to BookStack Action
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

## Inputs

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

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

### `bookstack-token-secret`
- **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.

### `chapter-id`
- **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

## Outputs
This action does not output anything, if everything goes well.

## Example usage

```yaml
uses: lazybytez/sync-markdown-bookstack-action@1.0.0
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
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'
```
29 changes: 29 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: 'Sync Markdown to BookStack'
description: 'An action that syncs markdown files to a book or chapter in BookStack'
inputs:
bookstack-url:
description: 'The URL of the BookStack instance'
required: true
bookstack-token-id:
description: 'The id of your BookStack API connection'
required: true
bookstack-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:
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'
Loading