Skip to content

PI-1462 add api docs for tier to delius (#2291) #810

PI-1462 add api docs for tier to delius (#2291)

PI-1462 add api docs for tier to delius (#2291) #810

Workflow file for this run

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:
projects:
description: Project
type: choice
required: true
options:
- 'All'
- '["approved-premises-and-delius"]'
- '["approved-premises-and-oasys"]'
- '["court-case-and-delius"]'
- '["create-and-vary-a-licence-and-delius"]'
- '["custody-key-dates-and-delius"]'
- '["domain-events-and-delius"]'
- '["effective-proposal-framework-and-delius"]'
- '["external-api-and-delius"]'
- '["make-recall-decisions-and-delius"]'
- '["manage-pom-cases-and-delius"]'
- '["offender-events-and-delius"]'
- '["pathfinder-and-delius"]'
- '["person-search-index-from-delius"]'
- '["pre-sentence-reports-to-delius"]'
- '["prison-case-notes-to-probation"]'
- '["prison-custody-status-to-delius"]'
- '["refer-and-monitor-and-delius"]'
- '["risk-assessment-scores-to-delius"]'
- '["sentence-plan-and-delius"]'
- '["sentence-plan-and-oasys"]'
- '["soc-and-delius"]'
- '["tier-to-delius"]'
- '["unpaid-work-and-delius"]'
- '["workforce-allocations-to-delius"]'
- '["manage-offences-and-delius"]'
- '["resettlement-passport-and-delius"]'
- '["prison-education-and-delius"]'
- '["opd-and-delius"]'
# ^ add new projects here
# GitHub Actions doesn't support dynamic choices, we must add each project here to enable manual deployments
# See https://github.com/community/community/discussions/11795
deploy:
description: Deploy?
type: boolean
jobs:
get-projects:
runs-on: ubuntu-latest
outputs:
projects: ${{ steps.output.outputs.projects }}
steps:
- uses: actions/checkout@v4
- name: Get projects - all
if: github.event_name != 'workflow_dispatch' || inputs.projects == 'All'
run: echo "projects=$(find projects -mindepth 1 -maxdepth 1 -printf "%f\n" | jq --raw-input . | jq --slurp --compact-output .)" | tee -a "$GITHUB_ENV"
- name: Get projects - selected
if: github.event_name == 'workflow_dispatch' && inputs.projects != 'All'
run: echo 'projects=${{ inputs.projects }}' | tee -a "$GITHUB_ENV"
- id: output
run: echo 'projects=${{ env.projects }}' | 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@v3
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 is configured
id: check_config
run: echo "api_path=$(yq '.api_path' 'projects/${{ matrix.project }}/tech-docs/config/tech-docs.yml')" | tee -a "$GITHUB_OUTPUT"
- uses: actions/setup-java@v3
if: startsWith(steps.check_config.outputs.api_path, 'http')
with:
java-version: '17'
distribution: 'temurin'
- uses: gradle/gradle-build-action@v2 # enables caching
if: startsWith(steps.check_config.outputs.api_path, 'http')
with:
arguments: ${{ matrix.project }}:assemble
- name: Host OpenAPI spec
if: startsWith(steps.check_config.outputs.api_path, 'http')
run: |
./gradlew '${{ matrix.project }}:bootRun' &
timeout 120 sh -c 'until curl -s localhost:8080/v3/api-docs.yaml; do sleep 5; done'
yq -i '.api_path = "http://localhost:8080/v3/api-docs.yaml"' 'projects/${{ matrix.project }}/tech-docs/config/tech-docs.yml'
env:
SPRING_PROFILES_ACTIVE: dev
- name: Set branch
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: Build
run: |
gem install middleman
bundle exec middleman build --verbose
working-directory: projects/${{ matrix.project }}/tech-docs
- name: Bundle API specs
if: startsWith(steps.check_config.outputs.api_path, 'http')
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
- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.project }}
path: projects/${{ matrix.project }}/tech-docs/build
- name: Branch deploy
if: github.ref_name != 'main' && github.event_name == 'workflow_dispatch' && inputs.deploy
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: projects/${{ matrix.project }}/tech-docs/build
target-folder: tech-docs-drafts/${{ matrix.project }}
deploy:
runs-on: ubuntu-latest
timeout-minutes: 30
if: github.ref == 'refs/heads/main'
needs:
- build-index
- build-projects
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
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
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: tech-docs
target-folder: tech-docs