AsciiDoc Documentation Build #1835
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
name: AsciiDoc Documentation Build | |
on: | |
create: # new branches or tags | |
release: # new releases | |
pull_request: | |
branches: [ master ] | |
push: # on push. This may be removed later | |
schedule: # periodic - needed because some of the content is from the other repos | |
- cron: '30 5,20 * * *' # this is pretty often. Only needed during review phase | |
jobs: | |
asciidoctor-build: | |
name: Run Asciidoctor on Documentation | |
runs-on: ubuntu-22.04 | |
steps: | |
# Checkout osi documentation | |
- name: Checkout osi-documentation | |
uses: actions/checkout@v2 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
# Checkout all other OSI repositories with branch "migration" and nested into osi-documentation | |
- name: Checkout open-simulation-interface | |
uses: actions/checkout@v2 | |
with: | |
repository: OpenSimulationInterface/open-simulation-interface | |
path: content/open-simulation-interface | |
fetch-depth: 0 | |
- name: Checkout OSI Sensor Model Packaging | |
uses: actions/checkout@v2 | |
with: | |
repository: OpenSimulationInterface/osi-sensor-model-packaging | |
path: content/osi-sensor-model-packaging | |
- name: Checkout proto2cpp | |
uses: actions/checkout@v2 | |
with: | |
repository: OpenSimulationInterface/proto2cpp | |
path: proto2cpp | |
# Versioning | |
- name: Get versioning | |
id: get_version | |
working-directory: content/open-simulation-interface | |
run: echo ::set-output name=VERSION::$(git describe --always) | |
# replaces the placeholder for versioning in the main mapping file | |
- name: Apply versioning to Adoc | |
run: | | |
grep ":revnumber:" content/_config.adoc | |
sed -i -e "s/--localbuild--/main (${{ steps.get_version.outputs.VERSION }})/" content/_config.adoc | |
grep ":revnumber:" content/_config.adoc | |
- name: Remove docdate for online hosted document | |
run: sed 's/^:revdate:.*/:!revdate:/' content/_config.adoc | |
# run Asciidoctor | |
- name: Build HTML | |
uses: avattathil/asciidoctor-action@master | |
with: | |
program: "asciidoctor -D . --failure-level WARN -r asciidoctor-diagram -r asciidoctor-bibtex -a mathjax --trace --backend=html5 content/index.adoc -o open-simulation-interface_V${{ steps.get_version.outputs.VERSION }}.html" | |
# Upload artifact. | |
- name: Upload HTML Artifact | |
uses: actions/upload-artifact@v2 | |
if: ${{ github.event_name == 'pull_request' }} | |
with: | |
name: HTML document | |
path: open-simulation-interface_V${{ steps.get_version.outputs.VERSION }}.html | |
if-no-files-found: error | |
# Publish the artifact when pipeline runs on master | |
- name: rename file for deploy to gh-page | |
if: ${{ github.ref == 'refs/heads/master' }} | |
run: | | |
mkdir html/ | |
cp open-simulation-interface_V${{ steps.get_version.outputs.VERSION }}.html html/index.html | |
- name: deploy to gh-pages if push to master branch | |
if: ${{ github.ref == 'refs/heads/master' }} | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./html |