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

Reusable workflow for Antora #40

Merged
merged 1 commit into from
Sep 30, 2022
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
64 changes: 64 additions & 0 deletions .github/workflows/antora.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Generate documentation with Antora

on:
workflow_call:
inputs:
path:
type: string
required: false
default: './'
playbook:
type: string
required: false
default: 'local-antora-playbook.yml'
publish:
type: boolean
required: false
default: false

jobs:
docs:
name: Antora
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
# we don't know what commit the last tag was it's safer to get entire repo so previousStableVersion resolves
fetch-depth: 0

- name: Install NodeJS
uses: actions/setup-node@v3
with:
node-version: 16

- name: Get npm cache directory
id: npm-cache-dir
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v3
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-antora@3.1.1-lunr-extension@1.0.0-alpha.8
restore-keys: |
${{ runner.os }}-node-

- name: Install Antora and extensions
run: npm i -D -E --quiet --no-progress @antora/cli@3.1.1 @antora/site-generator@3.1.1 @antora/lunr-extension@1.0.0-alpha.8
Copy link
Member Author

@ihostage ihostage Sep 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Antora version doesn't variable because we must use the same version for all modules. We need a one place for bump this version.

working-directory: ${{ inputs.path }}

- name: Build documentation
run: npx antora ${{ inputs.playbook }}
working-directory: ${{ inputs.path }}

- name: Publish to GitHub Pages
if: ${{ inputs.publish }}
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ${{ inputs.path }}/build/site
force_orphan: true
commit_message: "Deploy docs"
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ This repository contains a few configurations of GitHub features. For example a
* [Publishing to Sonatype](#publishing-to-sonatype)
* [Validate Binary Compatibility](#validate-binary-compatibility)
* [Mark Pull Request as Ready To Merge](#mark-pull-request-as-ready-to-merge)
* [Generate documentation with Antora](#generate-documentation-with-antora)

### Universal CMD task

Expand Down Expand Up @@ -146,6 +147,33 @@ needs: # Should be latest
uses: playframework/.github/.github/workflows/rtm.yml@v2
```

### Generate documentation with Antora

This workflow is used for generate and optionally publish documentation with [Antora](http://antora.org).

**Path**: [`.github/workflows/antora.yml`](.github/workflows/antora.yml)

**Image**: [Ubuntu 20.04](https://hub.docker.com/layers/ubuntu/library/ubuntu/20.04/images/sha256-57df66b9fc9ce2947e434b4aa02dbe16f6685e20db0c170917d4a1962a5fe6a9?context=explore)

**Uses actions**:
* [Setup Node](https://github.com/actions/setup-node)
* [Cache](https://github.com/actions/cache)
* [GitHub Pages](https://github.com/peaceiris/actions-gh-pages)

**Parameters**:

| Parameter | Since | Required | Default | Description |
|-----------|-------|--------------------|-----------------------------|---------------------|
| path | 3.1.0 | :heavy_minus_sign: | `./` | Path with docs |
| playbook | 3.1.0 | :heavy_minus_sign: | `local-antora-playbook.yml` | Playbook file name |
| publish | 3.1.0 | :heavy_minus_sign: | false | Publish to GH Pages |

**How to use**:

```yaml
uses: playframework/.github/.github/workflows/antora.yml@v3
```

## GitHub Actions Starter workflows

TODO