Skip to content

Merge pull request #203 from sorru94/remove-unused-python #108

Merge pull request #203 from sorru94/remove-unused-python

Merge pull request #203 from sorru94/remove-unused-python #108

Workflow file for this run

# This file is part of Astarte.
#
# Copyright 2023 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 for Github Pages
on:
push:
branches:
- 'master'
- 'release-*'
jobs:
api-docs:
runs-on: ubuntu-latest
steps:
# Checkout the source
- uses: actions/checkout@v4
with:
path: astarte-device-sdk-python
# Checkout the docs repository
- uses: actions/checkout@v4
with:
repository: astarte-platform/docs
ssh-key: ${{ secrets.DOCS_DEPLOY_KEY }}
path: docs
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install dependencies
working-directory: ./astarte-device-sdk-python/docs
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -e ..
- name: Generate Javadocs with Sphinx-doc
working-directory: ./astarte-device-sdk-python/docs
run: |
sphinx-apidoc -f -o . ../astarte
make html
- name: Copy Docs
run: |
export DOCS_DIRNAME="device-sdks/python/$(echo ${{ github.ref }} | sed 's,refs/heads/,,' | sed 's/master/snapshot/g' | sed 's/release-//g')/api"
rm -rf docs/$DOCS_DIRNAME
mkdir -p docs/$DOCS_DIRNAME
cp -r astarte-device-sdk-python/docs/_build/html/* docs/$DOCS_DIRNAME/
- name: Commit files
working-directory: ./docs
run: |
git config --local user.email "astarte-machine@ispirata.com"
git config --local user.name "Astarte Bot"
git add .
git diff-index --quiet HEAD || git commit -m "Update Python SDK documentation"
- name: Push changes
working-directory: ./docs
run: |
git push origin master
get-started-docs:
runs-on: ubuntu-latest
steps:
# Checkout the source
- uses: actions/checkout@v4
with:
path: astarte-device-sdk-python
fetch-depth: 0
# Checkout the sdk-doc repository
- uses: actions/checkout@v4
with:
repository: astarte-platform/sdk-doc
ssh-key: ${{ secrets.SDK_DOC_DEPLOY_KEY }}
path: sdk-doc
- name: Check release branch
id: check-release-branch
working-directory: ./astarte-device-sdk-python
shell: bash
run: |
latest_release=$(git branch -r | grep "release-*" | sort -t '-' -k 2,2n | tail -n 1 | cut -d '/' -f 2)
current_branch=$(git branch --show-current)
if [[ "$current_branch" == "$latest_release" ]]; then
echo "Current branch is the latest release branch"
echo "RESULT=OK" >> $GITHUB_OUTPUT
else
echo "Current branch is not the latest release branch"
echo "RESULT=FAILED" >> $GITHUB_OUTPUT
fi
- name: Compare and copy get started
id: cmp-and-copy-get-started
if: steps.check-release-branch.outputs.RESULT == 'OK'
run: |
our_get_started="./astarte-device-sdk-python/get_started.md"
their_get_started="./sdk-doc/source/get_started/python.md"
if cmp -s "$our_get_started" "$their_get_started"; then
echo "Get started are identical, no need for substitution"
echo "RESULT=NO_SUBSTITUTION" >> $GITHUB_OUTPUT
else
echo "Our get started is different, substituting theirs"
cp "$our_get_started" "$their_get_started"
echo "RESULT=SUBSTITUTION" >> $GITHUB_OUTPUT
fi
- name: Commit changes
id: commit-changes
if: steps.cmp-and-copy-get-started.outputs.RESULT == 'SUBSTITUTION'
working-directory: ./sdk-doc
run: |
git config --local user.email "astarte-machine@ispirata.com"
git config --local user.name "Astarte Bot"
git add .
git diff-index --quiet HEAD || git commit -m "Update Python SDK get started"
- name: Push changes
if: steps.commit-changes.conclusion == 'success'
working-directory: ./sdk-doc
run: |
git push origin master