|
| 1 | +name: Main - Continuous Integration |
| 2 | + |
| 3 | +concurrency: |
| 4 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 5 | + cancel-in-progress: true |
| 6 | + |
| 7 | +on: |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: read |
| 14 | + pages: write |
| 15 | + id-token: write |
| 16 | + |
| 17 | +jobs: |
| 18 | + ci: |
| 19 | + name: Continuous Integration |
| 20 | + uses: ./.github/workflows/__shared-ci.yml |
| 21 | + secrets: inherit |
| 22 | + |
| 23 | + docs-generate-site: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + needs: ci |
| 26 | + steps: |
| 27 | + - uses: actions/checkout@v4 |
| 28 | + - run: | |
| 29 | + mkdir -p ./_site |
| 30 | +
|
| 31 | + echo -e "theme: jekyll-theme-cayman" > ./_site/_config.yml |
| 32 | +
|
| 33 | + to_title_case() { |
| 34 | + echo "$1" | awk '{ |
| 35 | + for (i=1; i<=NF; i++) { |
| 36 | + $i = toupper(substr($i, 1, 1)) tolower(substr($i, 2)) |
| 37 | + } |
| 38 | + print |
| 39 | + }' |
| 40 | + } |
| 41 | +
|
| 42 | + create_site_page() { |
| 43 | + page="$1" |
| 44 | + title="$(to_title_case "$2")" |
| 45 | + content_path="$3" |
| 46 | + echo -e "---\nlayout: default\ntitle: $title\n---\n" > "$page" |
| 47 | + echo "$(sed -r s"/(\{%[^%]+%\})/{% raw %}\1{% endraw %}/g" "$content_path")" >> "$page" |
| 48 | + } |
| 49 | +
|
| 50 | + create_site_page "./_site/index.md" "Home" "./README.md" |
| 51 | +
|
| 52 | + for filepath in ./docs/*.md; do |
| 53 | + filename=$(basename -- "$filepath") |
| 54 | + section="${filename%.*}" |
| 55 | + mkdir -p "./_site/$section" |
| 56 | + create_site_page "./_site/$section/index.md" "$section" "$filepath" |
| 57 | + done |
| 58 | +
|
| 59 | + - uses: actions/upload-artifact@v4 |
| 60 | + with: |
| 61 | + name: docs-site |
| 62 | + path: ./_site |
| 63 | + |
| 64 | + docs-generate-phpdoc: |
| 65 | + runs-on: ubuntu-latest |
| 66 | + needs: ci |
| 67 | + steps: |
| 68 | + - uses: actions/checkout@v4 |
| 69 | + |
| 70 | + - name: 📃 Generate PHP documentation |
| 71 | + run: docker run --rm -v $(pwd):/data phpdoc/phpdoc:3 -d ./src -t ./_site/phpdoc |
| 72 | + |
| 73 | + - uses: actions/upload-artifact@v4 |
| 74 | + with: |
| 75 | + name: docs-phpdoc |
| 76 | + path: ./_site |
| 77 | + |
| 78 | + docs-publish: |
| 79 | + name: Publish documentation |
| 80 | + needs: [docs-generate-site, docs-generate-phpdoc] |
| 81 | + runs-on: ubuntu-latest |
| 82 | + permissions: |
| 83 | + pages: write |
| 84 | + id-token: write |
| 85 | + environment: |
| 86 | + name: github-pages |
| 87 | + url: ${{ steps.deployment.outputs.page_url }} |
| 88 | + steps: |
| 89 | + |
| 90 | + - uses: actions/download-artifact@v4 |
| 91 | + with: |
| 92 | + pattern: 'docs-*' |
| 93 | + path: ./ |
| 94 | + merge-multiple: true |
| 95 | + |
| 96 | + - name: ⚙️ Setup Pages |
| 97 | + uses: actions/configure-pages@v5 |
| 98 | + |
| 99 | + - name: Build with Jekyll |
| 100 | + uses: actions/jekyll-build-pages@v1 |
| 101 | + with: |
| 102 | + source: ./ |
| 103 | + destination: ./_site |
| 104 | + |
| 105 | + - name: Upload artifact |
| 106 | + uses: actions/upload-pages-artifact@v3 |
| 107 | + |
| 108 | + - name: 🚀 Deploy to GitHub Pages |
| 109 | + id: deployment |
| 110 | + uses: actions/deploy-pages@v4 |
0 commit comments