diff --git a/.github/workflows/check-documentation.yml b/.github/workflows/check-documentation.yml new file mode 100644 index 000000000..e75224ce4 --- /dev/null +++ b/.github/workflows/check-documentation.yml @@ -0,0 +1,77 @@ +name: ocelot.social check documentation + +on: + push: + branches: + - trigger-docs.ocelot.social-deployment-by-markdown-file-changes-in-master-branch + +jobs: + files-changed: + name: Detect File Changes - Markdown files + runs-on: ubuntu-latest + outputs: + markdown-files: ${{ steps.changes.outputs.markdown-files }} + steps: + - name: Checkout code + uses: actions/checkout@master + + - name: Check for markdown file changes + uses: dorny/paths-filter@v2.11.1 + id: changes + with: + token: ${{ github.token }} + filters: .github/file-filters.yml + list-files: shell + + check-summary: + name: Check documentation summary + if: needs.files-changed.outputs.markdown-files == 'true' + needs: files-changed + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@master + + - name: Check, if all .md files listed in SUMMARY.dm exist in current branch + run: | + if [ ! -f "SUMMARY.md" ]; then + echo "The file SUMMARY.md does not exist." + exit 1 + fi + + md_files=$(grep -o -P '\[[^\]]+\]\(([^)]+\.md)\)' SUMMARY.md | sed -r 's/.*\(([^)]+)\)/\1/') + missing_files=() + + for file in $md_files; do + if [ ! -f "$file" ]; then + missing_files+=("$file") + fi + done + + if [ ${#missing_files[@]} -eq 0 ]; then + echo "All .md files listed in SUMMARY.dm exist." + else + echo "These files listed in SUMMARY.dm do not exist:" + for missing_file in "${missing_files[@]}"; do + echo "$missing_file" + done + exit 1 + fi + + check-markdown-links: + name: Check Markdown links + if: needs.files-changed.outputs.markdown-files == 'true' + needs: files-changed + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@master + - name: Check Markdown Links + uses: gaurav-nelson/github-action-markdown-link-check@master + with: + use-quiet-mode: 'yes' + use-verbose-mode: 'no' + check-modified-files-only: 'no' + config-file: '.github/workflows/mlc_config.json' + base-branch: 'trigger-docs.ocelot.social-deployment-by-markdown-file-changes-in-master-branch' # set to branch of current PR's branch + folder-path: '.'