-
Notifications
You must be signed in to change notification settings - Fork 1
132 lines (114 loc) · 4.45 KB
/
site-build.yml
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
131
132
name: ASAM OSI build
on:
push: # on push
branches:
- main
# schedule: # periodic - needed because some of the content is from the other repos
# - cron: '30 5,20 * * *' # twice per day, in the morning and evening.
repository_dispatch:
types: [antora-build-trigger]
workflow_dispatch:
jobs:
build:
name: Build OSI documentation and deploy it to gh-pages
runs-on: ubuntu-20.04
services:
kroki:
image: yuzutech/kroki:0.15.1
env:
KROKI_MAX_URI_LENGTH: 8000
KROKI_BLOCKDIAG_HOST: blockdiag
KROKI_MERMAID_HOST: mermaid
blockdiag:
image: yuzutech/kroki-blockdiag:0.15.1
mermaid:
image: yuzutech/kroki-mermaid:0.15.1
steps:
# checkout repo into folder guide. This is done to match the setup for the local build in docker-compose
- name: Checkout with submodules
uses: actions/checkout@v4
with:
path: repo
fetch-depth: 0 # test if depth in fetch history is required
submodules: recursive
# - name: Submodules
# working-directory: repo
# env:
# ASAM_ANTORA_EXTENSIONS: ${{ secrets.ASAM_ANTORA_EXTENSIONS }}
# run: git clone --recurse-submodules https://asam-antora-extensions:$ASAM_ANTORA_EXTENSIONS@code.asam.net/common/asam-antora-extensions.git
- name: Checkout documentation
if: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.head_ref }}
uses: actions/checkout@v4
with:
repository: OpenSimulationInterface/osi-documentation
path: repo/osi-documentation
fetch-depth: 0 # test if depth in fetch history is required
- name: Checkout interface
if: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.head_ref }}
uses: actions/checkout@v4
with:
repository: OpenSimulationInterface/open-simulation-interface
path: repo/open-simulation-interface
fetch-depth: 0 # test if depth in fetch history is required
- name: Checkout OSMP
if: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.head_ref }}
uses: actions/checkout@v4
with:
repository: OpenSimulationInterface/osi-sensor-model-packaging
path: repo/osi-sensor-model-packaging
fetch-depth: 0 # test if depth in fetch history is required
- name: Apply dispatch information
if: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.head_ref }}
working-directory: repo
run: |
SRC=${{ github.event.client_payload.src }}
IFS="/"
SRC_REPO=($SRC)
unset IFS
SRC_REPO=${SRC_REPO[1]}
HEAD_REF=${{ github.event.client_payload.head_ref }}
echo Branch build for ${HEAD_REF} in ${SRC_REPO}
sed -i -r "s|\[(.*)\] # o|[\1,HEAD] # ${SRC_REPO} # o|g" site.yml
sed -i -r "s|(- url: .*# retrieve content from remote)|# \1|g" site.yml
sed -i -r "s|# (- url: .*# retrieve content locally)|\1|g" site.yml
echo Checking out the target branch
cd open-simulation-interface
git checkout ${HEAD_REF} 2>/dev/null || git checkout -b ${HEAD_REF}
cd ..
cd osi-documentation
git checkout ${HEAD_REF} 2>/dev/null || git checkout -b ${HEAD_REF}
cd ..
cd osi-sensor-model-packaging
git checkout ${HEAD_REF} 2>/dev/null || git checkout -b ${HEAD_REF}
cd ..
# build site
- name: Generate site
uses: docker://ghcr.io/asam-ev/project-guide-docker:4
with:
entrypoint: sh
args: repo/run-build.sh
- name: Upload pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./repo/site
deploy:
# Run if it was not triggered from remote OR the remote source was master or main.
if: ${{ github.event_name != 'repository_dispatch' || contains(github.event.client_payload.ref, 'master') || contains(github.event.client_payload.ref, 'main') }}
# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true
needs: build
permissions:
actions: read
pages: write
id-token: write
# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy
id: deployment
uses: actions/deploy-pages@v4