-
Notifications
You must be signed in to change notification settings - Fork 30
108 lines (94 loc) · 3.68 KB
/
docs-as-code.yaml
File metadata and controls
108 lines (94 loc) · 3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: Publish Portal Content
on:
push:
branches:
- main
paths:
- 'docs/**'
release:
types: [published]
paths:
- 'docs/**'
workflow_dispatch:
inputs:
environment:
description: 'Deployment environment: Production or Staging'
required: false
default: 'Staging'
log_level:
description: 'Log level: 1=DEBUG, 2=INFO, 3=WARNING, 4=ERROR'
required: false
default: '2' # Set the default log level to INFO
permissions: read-all
env:
LOG_LEVEL: ${{ github.event.inputs.log_level }}
jobs:
spell-check:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: '20'
- name: Run cspell
run: npx -y cspell --config ./.cspell.json "./docs/**/*.md"
validate-manifests:
runs-on: ubuntu-latest
needs: spell-check
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: '20'
- name: Validate manifests
run: |
. ./docs/scripts/utilities.sh
for product in ./docs/products/*; do
if [[ -d "$product" ]]; then
product_name=${product#./docs/products/}
manifest="./docs/products/$product_name/manifest.json"
if [[ -f "$manifest" ]]; then
# Further actions...
log_message $INFO "Validating manifest in product: $product_name"
log_message $DEBUG "Validating manifest: $manifest"
npx -y ajv-cli validate -s ./docs/schemas/manifest.schema.json -d "$manifest" --spec=draft2020
fi
fi
done
publish:
runs-on: ubuntu-latest
environment: ${{ github.event_name == 'release' && 'Production' || github.event.inputs.environment || 'Staging' }}
needs: [spell-check, validate-manifests]
if: github.event.inputs.skip_api_linting == 'true' || (needs.spell-check.result == 'success' && needs['validate-manifests'].result == 'success')
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Publish docs to Portal
shell: bash
run: |
for product in ./docs/products/*; do
echo "Product: $product"
if [[ -d "$product" ]]; then
echo "Product is a directory"
product_name=${product#./docs/products/}
echo "Product name: $product_name"
manifest="./docs/products/$product_name/manifest.json"
echo "Manifest: $manifest"
if [[ -f "$manifest" ]]; then
echo "Manifest is a file"
. ./docs/scripts/publish-portal-content.sh && portal_product_upsert "$manifest" "$product_name"
. ./docs/scripts/publish-portal-content.sh && load_and_process_product_manifest_content_metadata "$manifest" "$product_name"
else
echo "Manifest is not a file"
fi
else
echo "Product is not a directory"
fi
done
env:
SWAGGERHUB_PORTAL_SUBDOMAIN: ${{ vars.SWAGGERHUB_PORTAL_SUBDOMAIN }}
SWAGGERHUB_API_KEY: ${{ secrets.SWAGGERHUB_API_KEY }}