Documentation build #237
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
# SPDX-License-Identifier: MIT | |
name: Documentation build | |
on: | |
workflow_dispatch: | |
inputs: | |
publish-documentation: | |
description: Insert your email address here if you want to create a PR for Github pages update (branch `master`) | |
required: false | |
schedule: | |
# Nightly build documentation: | |
# cron runs on the default branch: `develop` in our case. | |
- cron: '32 23 * * *' | |
env: | |
ACTIONS_SECHUB_DOC_RELEASE_BRANCH: master | |
jobs: | |
build-documentation: | |
name: build documentation | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Show + check Input and git branch" | |
run: | | |
echo "git branch: '${{ github.ref_name }}'" | |
echo "publish-documentation: '${{ inputs.publish-documentation }}'" | |
if [ '${{ inputs.publish-documentation }}' != '' -a '${{ github.ref_name }}' != "$ACTIONS_SECHUB_DOC_RELEASE_BRANCH" ] ; then | |
echo "Aborting run because publishing the documentation must be done on branch '$ACTIONS_SECHUB_DOC_RELEASE_BRANCH'" | |
echo "Tip: Run this action again and select branch '$ACTIONS_SECHUB_DOC_RELEASE_BRANCH'" | |
exit 1 | |
fi | |
- name: Git checkout | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 | |
with: | |
fetch-tags: true | |
fetch-depth: 0 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@2dfa2011c5b2a0f1489bf9e433881c92c1631f88 | |
with: | |
java-version: 17 | |
distribution: temurin | |
- name: Set up Gradle | |
uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808 | |
with: | |
cache-read-only: false | |
- name: Set up Go | |
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 | |
with: | |
go-version: 1.21.6 | |
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 | |
with: | |
path: | | |
~/.cache/go-build | |
~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- name: Install graphviz (asciidoc diagrams) | |
run: sudo apt-get --assume-yes install graphviz | |
# ----------------------------------------- | |
# Build documentation | |
# ----------------------------------------- | |
- name: Complete build with documentation | |
run: ./buildDoc | |
# ----------------------------------------- | |
# Upload documentation | |
# ----------------------------------------- | |
- name: Archive documentation HTML | |
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 | |
with: | |
name: sechub-docs-html | |
path: sechub-doc/build/docs/final-html/ | |
retention-days: 14 | |
- name: Archive documentation PDF | |
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 | |
with: | |
name: sechub-docs-pdf | |
path: sechub-doc/build/docs/asciidoc/*.pdf | |
retention-days: 14 | |
# ----------------------------------------- | |
# Update and commit documentation for https://mercedes-benz.github.io/sechub/ | |
# ----------------------------------------- | |
- name: Update documentation - publish and commit | |
if: (inputs.publish-documentation != '') && (github.ref_name == env.ACTIONS_SECHUB_DOC_RELEASE_BRANCH) | |
run: | | |
git config user.name "$GITHUB_TRIGGERING_ACTOR (via github-actions)" | |
git config user.email "${{ inputs.publish-documentation }}" | |
git reset --hard | |
sechub-doc/helperscripts/publish+git-add-releasedocs.sh | |
git commit -m "docs update by '$GITHUB_TRIGGERING_ACTOR' (via github-actions)" | |
# ----------------------------------------- | |
# Create pull request for documentation update | |
# ----------------------------------------- | |
- name: Update documentation - Create pull request | |
if: (inputs.publish-documentation != '') && (github.ref_name == env.ACTIONS_SECHUB_DOC_RELEASE_BRANCH) | |
id: pr_release_documentation | |
uses: peter-evans/create-pull-request@6cd32fd93684475c31847837f87bb135d40a2b79 | |
with: | |
branch: release-documentation | |
branch-suffix: short-commit-hash | |
delete-branch: true | |
title: '1 - Release documentation [auto-generated]' | |
body: | | |
Release of SecHub documentation | |
-> Please review before merge. | |
- name: Update documentation - Print PR infos | |
if: (inputs.publish-documentation != '') && (github.ref_name == env.ACTIONS_SECHUB_DOC_RELEASE_BRANCH) | |
run: | | |
echo "Pull Request Number - ${{ steps.pr_release_documentation.outputs.pull-request-number }}" | |
echo "Pull Request URL - ${{ steps.pr_release_documentation.outputs.pull-request-url }}" |