PI-2543 Create initial project for appointment-reminders-and-delius (… #1663
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: Documentation | |
on: | |
push: | |
paths: | |
- .github/workflows/docs.yml | |
- projects/**/tech-docs/** | |
- doc/tech-docs/** | |
schedule: | |
- cron: "30 5 * * MON-FRI" # Every weekday at 05:30 UTC | |
workflow_dispatch: | |
inputs: | |
deploy: | |
description: Deploy? | |
type: boolean | |
jobs: | |
get-projects: | |
runs-on: ubuntu-latest | |
outputs: | |
projects: ${{ steps.output.outputs.projects }} | |
steps: | |
- uses: actions/checkout@v4 | |
- id: output | |
run: echo "projects=$(cd projects && find . -name tech-docs -exec dirname {} \; | sed 's#^\./##' | jq --raw-input . | jq --slurp --compact-output .)" | tee -a "$GITHUB_OUTPUT" | |
build-index: | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 3.1 | |
bundler-cache: true | |
working-directory: doc/tech-docs | |
- name: Build | |
run: | | |
gem install middleman | |
bundle exec middleman build --verbose | |
working-directory: doc/tech-docs | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: index | |
path: doc/tech-docs/build | |
build-projects: | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
needs: get-projects | |
strategy: | |
fail-fast: false | |
matrix: | |
project: ${{ fromJson(needs.get-projects.outputs.projects) }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 3.1 | |
bundler-cache: true | |
working-directory: projects/${{ matrix.project }}/tech-docs | |
- name: Check if OpenAPI or AsyncAPI is configured | |
id: check_config | |
run: | | |
echo "has_rest_api=$(yq '. | has("api_path")' 'projects/${{ matrix.project }}/tech-docs/config/tech-docs.yml')" | tee -a "$GITHUB_OUTPUT" | |
echo "has_async_api=$(test -f 'projects/${{ matrix.project }}/tech-docs/source/asyncapi-reference.html.md.erb' && echo 'true' || echo 'false')" | tee -a "$GITHUB_OUTPUT" | |
- uses: actions/setup-java@v4 | |
if: steps.check_config.outputs.has_rest_api == 'true' || steps.check_config.outputs.has_async_api == 'true' | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
- uses: gradle/actions/setup-gradle@v4 | |
if: steps.check_config.outputs.has_rest_api || steps.check_config.outputs.has_async_api | |
with: | |
cache-read-only: true | |
- name: Host API specs | |
if: steps.check_config.outputs.has_rest_api == 'true' || steps.check_config.outputs.has_async_api == 'true' | |
run: | | |
./gradlew '${{ matrix.project }}:bootRun' & | |
timeout 300 sh -c 'until curl -s localhost:8080/v3/api-docs.yaml; do sleep 5; done' | |
env: | |
SPRING_PROFILES_ACTIVE: dev | |
- name: Update configured OpenAPI path | |
if: steps.check_config.outputs.has_rest_api == 'true' | |
run: yq -i '.api_path = "http://localhost:8080/v3/api-docs.yaml"' 'projects/${{ matrix.project }}/tech-docs/config/tech-docs.yml' | |
- name: Set branch in index | |
if: github.ref_name != 'main' | |
run: sed -i "s|$REPOSITORY/main|$REPOSITORY/$BRANCH|" index.html.md.erb | |
working-directory: projects/${{ matrix.project }}/tech-docs/source | |
env: | |
REPOSITORY: ${{ github.repository }} | |
BRANCH: ${{ github.ref_name }} | |
- name: Set branch in asyncapi-reference | |
if: github.ref_name != 'main' && steps.check_config.outputs.has_async_api == 'true' | |
run: sed -i "s|/tech-docs/|/tech-docs-drafts/$BRANCH/|" asyncapi-reference.html.md.erb | |
working-directory: projects/${{ matrix.project }}/tech-docs/source | |
env: | |
REPOSITORY: ${{ github.repository }} | |
BRANCH: ${{ github.ref_name }} | |
- name: Build | |
run: | | |
gem install middleman | |
bundle exec middleman build --verbose | |
working-directory: projects/${{ matrix.project }}/tech-docs | |
- name: Bundle OpenAPI specs | |
if: steps.check_config.outputs.has_rest_api == 'true' | |
run: | | |
curl -sf localhost:8080/v3/api-docs -o api-docs.json | |
curl -sf localhost:8080/v3/api-docs.yaml -o api-docs.yaml | |
working-directory: projects/${{ matrix.project }}/tech-docs/build | |
- name: Bundle AsyncAPI specs | |
if: steps.check_config.outputs.has_async_api == 'true' | |
run: | | |
curl -sf localhost:8080/docs/asyncapi -o asyncapi-docs.json | |
working-directory: projects/${{ matrix.project }}/tech-docs/build | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.project }} | |
path: projects/${{ matrix.project }}/tech-docs/build | |
post-build: | |
name: Post-build | |
runs-on: ubuntu-latest | |
needs: | |
- build-index | |
- build-projects | |
if: always() | |
steps: | |
- name: Check build matrix status | |
if: ${{ needs.build-index.result != 'success' || needs.build-projects.result != 'success' }} | |
run: exit 1 | |
deploy: | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
if: github.ref_name == 'main' || (github.event_name == 'workflow_dispatch' && inputs.deploy) | |
needs: | |
- build-index | |
- build-projects | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
path: artifacts | |
- name: Merge artifacts | |
run: | | |
mv artifacts/index/ tech-docs | |
mkdir -p tech-docs/projects | |
find artifacts -mindepth 1 -maxdepth 1 -print0 | xargs -0 -L1 basename | xargs -I{} mv 'artifacts/{}' 'tech-docs/projects/{}/' | |
- name: Deploy main | |
if: github.ref_name == 'main' | |
uses: JamesIves/github-pages-deploy-action@881db5376404c5c8d621010bcbec0310b58d5e29 # v4.6.8 | |
with: | |
folder: tech-docs | |
target-folder: tech-docs | |
- name: Deploy branch | |
if: github.ref_name != 'main' | |
uses: JamesIves/github-pages-deploy-action@881db5376404c5c8d621010bcbec0310b58d5e29 # v4.6.8 | |
with: | |
folder: tech-docs | |
target-folder: tech-docs-drafts/${{ github.ref_name }} |