Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/actions/doc-generate/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#
# This file is part of Edgehog.
#
# Copyright 2026 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: Docs generation
inputs:
edgehog:
description: "The edgehog project location."
required: true
docs:
description: "The docs project location."
required: true
astarte-interfaces:
description: "The astarte-interfaces project location."
required: true
version:
description: "The docs version to build."
required: true

permissions:
contents: read

runs:
using: "composite"
steps:
- uses: actions/setup-node@v6
with:
node-version-file: ${{ inputs.edgehog }}/.tool-versions
- name: Install astarte-docs-cli
shell: bash
run: npm install -g @astarte-platform/astarte-docs-cli@0.0.7
- name: Symlink `tool-versions` to use edgehog's tool versions
shell: bash
run: |
ln -s ${{ inputs.edgehog }}/.tool-versions .tool-versions
- uses: team-alembic/staple-actions/actions/mix-task@main
with:
working-directory: ${{ inputs.edgehog }}/backend
mix-env: dev
task: edgehog.docs --interfaces-path "${{ github.workspace }}/${{ inputs.astarte-interfaces }}"
- name: Generate doc versions
shell: bash
working-directory: ${{ inputs.edgehog }}
run: |
./tools/gen-docs-versions.sh > ${{ github.workspace }}/${{ inputs.docs }}/versions.js
- name: Move doc to docs folder
shell: bash
run: |
cp -r "${{ inputs.edgehog }}/backend/doc" "${{ github.workspace }}/${{ inputs.docs }}/${{ inputs.version }}"
- name: link `versions.js`
shell: bash
working-directory: ${{ inputs.docs }}/${{ inputs.version }}
run: |
ln -s ../versions.js docs_config.js
- uses: actions/upload-artifact@v7
with:
name: edgehog-docs-bundle
path: ${{ inputs.docs }}
49 changes: 49 additions & 0 deletions .github/actions/doc-publish/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#
# This file is part of Edgehog.
#
# Copyright 2026 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 doc publication
inputs:
docs:
description: "The docs project location."
required: true

defaults:
run:
shell: bash

runs:
using: "composite"
steps:
- name: Commit files
working-directory: ${{ inputs.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
12 changes: 3 additions & 9 deletions .github/release-please/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,21 @@
"package-name": "backend",
"release-type": "elixir",
"component": "backend",
"include-component-in-tag": false
},
"doc": {
"package-name": "doc",
"release-type": "elixir",
"component": "doc",
"include-component-in-tag": false
"include-component-in-tag": true
},
"frontend": {
"package-name": "frontend",
"release-type": "node",
"component": "frontend",
"include-component-in-tag": false
"include-component-in-tag": true
}
},
"plugins": [
{
"type": "linked-versions",
"groupName": "edgehog",
"tagName": "v${version}",
"components": ["backend", "frontend", "doc"]
"components": ["backend", "frontend"]
}
],
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
Expand Down
1 change: 0 additions & 1 deletion .github/release-please/manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"backend": "0.12.0",
"doc": "0.12.0",
"frontend": "0.12.0"
}
6 changes: 6 additions & 0 deletions .github/workflows/backend-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,9 @@ jobs:
uses: ./.github/workflows/backend-azurite.yaml
docker-build:
uses: ./.github/workflows/backend-docker-build.yaml
docs:
uses: ./.github/workflows/docs-workflow.yaml
with:
release-made: false
release-version: snapshot
publish: false
161 changes: 42 additions & 119 deletions .github/workflows/docs-workflow.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# This file is part of Edgehog.
#
# Copyright 2021 - 2026 SECO Mind Srl
# Copyright 2021-2026 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.
Expand All @@ -16,47 +16,49 @@
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

name: Edgehog docs generation

# publish Generate and publish docs on pushes on main (or release branches) only
# when backend or frontend files are touched.
on:
push:
paths:
# Documentation pages
- "doc/**"
# Schema files
- "backend/lib/edgehog_web/admin_api/**"
- "backend/lib/edgehog_web/schema.ex"
- "backend/lib/edgehog_web/schema/**"
# Ash resources, including new Ash domains
- "backend/lib/edgehog/**"
- "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-*"
workflow_call:
inputs:
release-made:
required: true
type: boolean
release-version:
type: string
publish:
type: boolean
default: true

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
defaults:
run:
shell: bash

jobs:
docs:
if: github.repository_owner == 'edgehog-device-manager'
runs-on: ubuntu-22.04
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout the source
uses: actions/checkout@v6
with:
path: edgehog
show-progress: false
fetch-tags: true
- name: Checkout the docs repository
uses: actions/checkout@v6
with:
Expand All @@ -69,97 +71,18 @@ jobs:
repository: edgehog-device-manager/edgehog-astarte-interfaces
path: edgehog-astarte-interfaces
show-progress: false
- uses: actions/setup-node@v6
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: Setup Node.js 22 for SpectaQL
uses: actions/setup-node@v6
with:
node-version: "22"
- 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@v6
with:
repository: swagger-api/swagger-ui
path: ./edgehog/backend/swagger-ui
ref: "v5.30.2"
- 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
- name: Compute docs version
id: compute-version
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
# 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/

# Upload as an artifact the generated HTML
- name: Upload HTML documentation
uses: actions/upload-artifact@v7
version=$(${{ inputs.release-made }} && echo ${{ inputs.release-version }} || echo "snapshot")
echo "version=$version" >> $GITHUB_OUTPUT
- uses: ./edgehog/.github/actions/doc-generate
with:
name: docs_html
path: ./docs

# Commit and push changes to the docs repository
- 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
edgehog: edgehog
docs: docs
astarte-interfaces: edgehog-astarte-interfaces
version: ${{ steps.compute-version.outputs.version }}
- uses: ./edgehog/.github/actions/doc-publish
if: ${{ inputs.publish }}
with:
docs: docs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,20 @@ permissions:
issues: write
pull-requests: write

name: release-please
name: Release CI

jobs:
release-please:
make-release:
runs-on: ubuntu-latest
steps:
- uses: googleapis/release-please-action@v4
with:
config-file: .github/release-please/config.json
manifest-file: .github/release-please/manifest.json
publish-docs:
needs: [make-release]
uses: .github/workflows/docs-workflow.yaml
with:
release-made: ${{ needs.make-release.outputs.backend--release_created }}
release-version: ${{ needs.make-release.outputs.backend--version }}
publish: github.repository_owner == 'edgehog-device-manager'
Loading
Loading