-
Notifications
You must be signed in to change notification settings - Fork 7
130 lines (127 loc) · 4.65 KB
/
docs-workflow.yaml
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#
# This file is part of Astarte.
#
# Copyright 2023-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: Docs generation for Github Pages
on:
push:
branches:
# Create the docs only when it matters
- 'master'
- 'release-*'
jobs:
api-docs:
runs-on: ubuntu-latest
steps:
# Checkout the source
- uses: actions/checkout@v4
with:
path: astarte-device-sdk-csharp
# Checkout the docs repository
- uses: actions/checkout@v4
with:
repository: astarte-platform/docs
ssh-key: ${{ secrets.DOCS_DEPLOY_KEY }}
path: docs
- name: Install doxygen
run: |
sudo apt-get update
sudo apt-get -y install doxygen
- name: Build Docs
working-directory: ./astarte-device-sdk-csharp/docs
run: doxygen doxy_config
- name: Copy Docs
run: |
export DOCS_DIRNAME="device-sdks/csharp/$(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-csharp/docs/out/html/* docs/$DOCS_DIRNAME/
- name: Update symlink
working-directory: ./docs/device-sdks/csharp
run: |
rm -f "latest"
latest_version=$(ls -d * | grep -v snapshot | sort -V | tail -n 1)
if [ -z $latest_version ]; then latest_version="snapshot"; fi
ln -sf "$latest_version" latest
- 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 CSharp 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-csharp
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-csharp
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-csharp/GET_STARTED.md"
their_get_started="./sdk-doc/source/get_started/csharp.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 CSharp SDK get started"
- name: Push changes
if: steps.commit-changes.conclusion == 'success'
working-directory: ./sdk-doc
run: |
git push origin master