|
5 | 5 | paths: |
6 | 6 | # Documentation pages |
7 | 7 | - "doc/**" |
8 | | - # Swagger files |
9 | | - - "apps/*/priv/static/*.yaml" |
| 8 | + # API sources used to generate OpenAPI specs |
| 9 | + - "apps/astarte_appengine_api/**" |
| 10 | + - "apps/astarte_housekeeping/**" |
| 11 | + - "apps/astarte_pairing/**" |
| 12 | + - "apps/astarte_realm_management/**" |
10 | 13 | # The action itself |
11 | 14 | - ".github/workflows/docs-workflow.yaml" |
12 | 15 | branches: |
|
17 | 20 | create: |
18 | 21 |
|
19 | 22 | jobs: |
| 23 | + generate_openapi_specs: |
| 24 | + runs-on: ubuntu-22.04 |
| 25 | + strategy: |
| 26 | + fail-fast: false |
| 27 | + matrix: |
| 28 | + app: |
| 29 | + - name: astarte_appengine_api |
| 30 | + spec: Astarte.AppEngine.APIWeb.ApiSpec |
| 31 | + filename: astarte_appengine_api.yaml |
| 32 | + - name: astarte_housekeeping |
| 33 | + spec: Astarte.HousekeepingWeb.ApiSpec |
| 34 | + filename: astarte_housekeeping_api.yaml |
| 35 | + - name: astarte_pairing |
| 36 | + spec: Astarte.PairingWeb.ApiSpec |
| 37 | + filename: astarte_pairing.yaml |
| 38 | + - name: astarte_realm_management |
| 39 | + spec: Astarte.RealmManagementWeb.ApiSpec |
| 40 | + filename: astarte_realm_management.yaml |
| 41 | + |
| 42 | + steps: |
| 43 | + - uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2 |
| 44 | + - name: Generate ${{ matrix.app.name }} OpenAPI spec |
| 45 | + uses: team-alembic/staple-actions/actions/mix-task@a74b3b61209d35d45526df174766632f8aee03ed |
| 46 | + with: |
| 47 | + working-directory: apps/${{ matrix.app.name }} |
| 48 | + mix-env: test |
| 49 | + task: >- |
| 50 | + openapi.spec.yaml |
| 51 | + --spec ${{ matrix.app.spec }} |
| 52 | + --start-app=false |
| 53 | + --vendor-extensions=false |
| 54 | + ${{ matrix.app.filename }} |
| 55 | + - name: Upload ${{ matrix.app.name }} artifact |
| 56 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 |
| 57 | + with: |
| 58 | + name: ${{ matrix.app.name }}-openapi-spec |
| 59 | + path: apps/${{ matrix.app.name }}/${{ matrix.app.filename }} |
| 60 | + if-no-files-found: error |
| 61 | + retention-days: 1 |
| 62 | + |
20 | 63 | docs: |
| 64 | + needs: |
| 65 | + - generate_openapi_specs |
21 | 66 | runs-on: ubuntu-22.04 |
22 | 67 | steps: |
23 | 68 | # Checkout the source |
24 | 69 | - uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2 |
25 | 70 | with: |
26 | 71 | path: astarte |
| 72 | + - name: Make .tool-versions available for staple-actions |
| 73 | + run: cp astarte/.tool-versions . |
| 74 | + - name: Download OpenAPI specs |
| 75 | + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 |
| 76 | + with: |
| 77 | + path: ./astarte/generated-openapi |
| 78 | + pattern: "*-openapi-spec" |
| 79 | + merge-multiple: true |
27 | 80 | # Checkout the docs repository |
28 | 81 | - uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2 |
29 | 82 | with: |
|
51 | 104 | export DOCS_DIRNAME="astarte/$(echo ${{ github.ref }} | sed 's,refs/heads/,,' | sed 's/master/snapshot/g' | sed 's/release-//g')" |
52 | 105 | mkdir docs/$DOCS_DIRNAME/api |
53 | 106 | cp swagger-ui/dist/* docs/$DOCS_DIRNAME/api |
| 107 | + cp astarte/generated-openapi/*.yaml docs/$DOCS_DIRNAME/api/ |
54 | 108 | rm docs/$DOCS_DIRNAME/api/index.html |
55 | 109 | cp astarte/doc/swagger-ui-index.html docs/$DOCS_DIRNAME/api/index.html |
56 | 110 | - name: Commit files |
|
0 commit comments