Skip to content

Merge pull request #583 from rbino/update-deps-again #103

Merge pull request #583 from rbino/update-deps-again

Merge pull request #583 from rbino/update-deps-again #103

#
# This file is part of Edgehog.
#
# Copyright 2021-2024 SECO Mind Srl
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
name: Edgehog docs generation
on:
push:
paths:
# Documentation pages
- 'doc/**'
# Schema files
- 'backend/lib/edgehog_web/schema.ex'
- 'backend/lib/edgehog_web/schema/**'
- 'backend/mix.exs'
- 'backend/mix.lock'
# SpectaQL configuration file
- 'backend/.spectaql-config.yaml'
# The action itself, Elixir and Node.js versions
- '.tool-versions'
- '.github/workflows/docs-workflow.yaml'
branches:
# Create the snapshot only when it matters
- 'main'
- 'release-*'
jobs:
docs:
if: github.repository_owner == 'edgehog-device-manager'
runs-on: ubuntu-22.04
steps:
- name: Checkout the source
uses: actions/checkout@v4
with:
path: edgehog
show-progress: false
- name: Checkout the docs repository
uses: actions/checkout@v4
with:
repository: edgehog-device-manager/docs
path: docs
show-progress: false
- name: Checkout the interfaces repository
uses: actions/checkout@v4
with:
repository: edgehog-device-manager/edgehog-astarte-interfaces
path: edgehog-astarte-interfaces
show-progress: false
- uses: actions/setup-node@v3
with:
node-version-file: edgehog/.tool-versions
# This section builds the doc pages
- name: Install astarte-docs-cli
run: npm install -g @astarte-platform/astarte-docs-cli@0.0.7
- name: Generate Interfaces Docs
run: astarte-docs interfaces gen-markdown -d ./edgehog-astarte-interfaces -o ./edgehog/doc/pages/integrating/astarte_interfaces.md
- uses: erlef/setup-beam@v1
with:
version-file: edgehog/.tool-versions
version-type: strict
- name: Install Docs Dependencies
working-directory: ./edgehog/doc
run: mix deps.get
- name: Build Docs
working-directory: ./edgehog/doc
run: mix docs
# This section builds the GraphQL API docs
- name: Install Backend Dependencies
working-directory: ./edgehog/backend
run: mix deps.get
- name: Extract GraphQL Schema
working-directory: ./edgehog/backend
run: mix absinthe.schema.sdl --schema EdgehogWeb.Schema
- name: Install SpectaQL
run: npm install -g spectaql
- name: Build SpectaQL Docs
working-directory: ./edgehog/backend
run: npx spectaql .spectaql-config.yaml -t tenant-graphql-api
# This section builds the Admin REST API docs
- name: Extract Admin Schema
working-directory: ./edgehog/backend
run: mix openapi.spec.yaml --spec EdgehogWeb.AdminAPI
- name: Checkout Swagger UI
uses: actions/checkout@v2
with:
repository: swagger-api/swagger-ui
path: ./edgehog/backend/swagger-ui
ref: 'v5.17.14'
- name: Copy all Swagger UI files
working-directory: ./edgehog/backend
run: |
cp -r swagger-ui/dist/ admin-rest-api/
cp openapi.yaml admin-rest-api/
cp ../doc/swagger-ui-index.html admin-rest-api/index.html
# Copy docs over to the docs repository
- name: Copy Docs, preserving Device SDK docs
run: |
export DOCS_DIRNAME="$(echo ${{ github.ref }} | sed 's,refs/heads/,,' | sed 's/main/snapshot/g' | sed 's/release-//g')"
rm -rf docs/$DOCS_DIRNAME
mkdir docs/$DOCS_DIRNAME
# Restore Device SDK docs. Don't fail if they're not there.
cd docs && git restore $DOCS_DIRNAME/device-sdks || true && cd ..
# Copy doc pages
cp -r edgehog/doc/doc/* docs/$DOCS_DIRNAME/
# Copy version dropdown config
cp edgehog/doc/versions.js docs/
# Copy GraphQL docs
cp -r ./edgehog/backend/tenant-graphql-api docs/$DOCS_DIRNAME/
# Copy Admin REST API docs
cp -r ./edgehog/backend/admin-rest-api docs/$DOCS_DIRNAME/
- name: Commit files
working-directory: ./docs
run: |
git config --local user.email "edgehog-machine@ispirata.com"
git config --local user.name "Edgehog Bot"
git add .
git commit -m "Update Documentation"
- name: Push changes
working-directory: ./docs
run: |
eval `ssh-agent -t 60 -s`
echo "${{ secrets.DOCS_DEPLOY_KEY }}" | ssh-add -
mkdir -p ~/.ssh/
ssh-keyscan github.com >> ~/.ssh/known_hosts
git remote add topush "git@github.com:edgehog-device-manager/docs.git"
git fetch topush
git push topush main