test workflow #15
Workflow file for this run
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: Bundle & Host JSON schema | |
on: | |
push | |
# push: | |
# branches: | |
# - main | |
# paths: | |
# - 'schemas/**' | |
jobs: | |
check-version: | |
name: Check if the version has been updated | |
outputs: | |
has_changed: ${{ steps.check.outputs.has_changed }} | |
id: ${{ steps.versions.outputs.new_version }} | |
version: ${{ steps.versions.outputs.version_only }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 2 | |
- id: versions | |
run: | | |
NEW_VERSION=$(jq -r '.["$id"]' schemas/applications/schema/application.schema.json) | |
echo "new_version=${NEW_VERSION}" >> $GITHUB_OUTPUT | |
IFS='/' read -a id_array <<< "$NEW_VERSION" | |
echo "version_only=${id_array[1]}" >> $GITHUB_OUTPUT | |
git checkout HEAD^ | |
PREV_VERSION=$( jq -r '.["$id"]' schemas/applications/schema/application.schema.json) | |
echo "prev_version=${PREV_VERSION}" >> $GITHUB_OUTPUT | |
shell: bash | |
- uses: aica-technology/.github/.github/actions/[email protected] | |
id: check | |
with: | |
previous_version: ${{ steps.versions.outputs.prev_version }} | |
new_version: ${{ steps.versions.outputs.new_version }} | |
build: | |
needs: check-version | |
name: Bundle & Host JSON schema | |
runs-on: ubuntu-latest | |
if: ${{ needs.check-version.outputs.has_changed == 'true' }} | |
steps: | |
- uses: actions/checkout@v3 | |
# Build Docusaurus | |
- name: Setup node in docs | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "16" | |
cache: "npm" | |
cache-dependency-path: "docs/package-lock.json" | |
- name: Cache docusaurus | |
uses: actions/cache@v3 | |
with: | |
path: | | |
${{ github.workspace }}/docs/.docusaurus | |
key: | | |
${{ runner.os }}-docusaurus | |
restore-keys: | | |
${{ runner.os }}-docusaurus | |
- name: Install dependencies | |
run: | | |
npm ci --prefix docs | |
- name: Lint / Formatting | |
run: | | |
npm run typecheck --prefix docs | |
# TODO: should add more in the future if needed | |
- name: Build | |
run: | | |
npm run build --prefix docs | |
# Fetch API documentation | |
- uses: aica-technology/.github/.github/actions/[email protected] | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- uses: aica-technology/.github/.github/actions/[email protected] | |
id: ensure-image | |
with: | |
image_name: aica-technology/backend-api-docs | |
- name: Get API version to fetch | |
id: api-version | |
run: | | |
VER="$(cat docs/api.version)" | |
echo "Version: $VER" | |
echo "version=$VER" >> $GITHUB_OUTPUT | |
- name: Create directory | |
run: | | |
mkdir -p docs/build/api | |
- name: Extract Swagger from the built image | |
uses: aica-technology/.github/.github/actions/[email protected] | |
with: | |
image: ${{ steps.ensure-image.outputs.image_name }}:${{ steps.api-version.outputs.version }} | |
source: /index.html | |
destination: docs/build/api/index.html | |
# Bundle JSON schema | |
- name: Setup node in utils | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "16" | |
cache: "npm" | |
cache-dependency-path: "utils/package-lock.json" | |
- name: Install dependencies | |
run: | | |
cd utils | |
npm i | |
pip3 install javascript | |
- name: Bundle Schemas | |
run: | | |
python3 utils/bundle.py schemas/applications/schema/application.schema.json application.schema.json | |
mkdir -p docs/build/schema/${{ steps.versions.outputs.version }} | |
mv application.schema.json docs/build/schema${{ steps.versions.outputs.id }} | |
- name: Deploy | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: docs/build |