-
Notifications
You must be signed in to change notification settings - Fork 0
187 lines (161 loc) · 5.75 KB
/
manual-using-extra-docker-in-docker.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
name: manual-using-extra-docker-in-docker
on:
workflow_dispatch:
inputs:
rosver:
description: 'RouterOS Version'
required: true
default: "7.12.1"
start_path:
description: 'Starting path (space seperated)'
required: false
jobs:
job-using-extra-docker-in-docker:
runs-on: ubuntu-latest
env:
URLBASE: http://localhost:9180/rest
BASICAUTH: "admin:"
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Docker
uses: docker/setup-buildx-action@v1
- name: Install Docker Compose
run: sudo apt install docker-compose
- name: Allow `git`
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Run Docker Compose
run: |
ROUTEROS_VERSION=${{ github.event.inputs.rosver }}
ROUTEROS_IMAGE="chr-${ROUTEROS_VERSION}.vdi"
ROUTEROS_PATH="https://cdn.mikrotik.com/routeros/${ROUTEROS_VERSION}/${ROUTEROS_IMAGE}.zip"
echo $ROUTEROS_VERSION
echo $ROUTEROS_IMAGE
echo $ROUTEROS_PATH
echo `which docker-compose`
echo "version: '3'
services:
routeros:
build:
context: .
dockerfile: ./Dockerfile.chr-qemu
args:
ARG_ROUTEROS_VERSION: "${ROUTEROS_VERSION}"
restart: unless-stopped
cap_add:
- NET_ADMIN
devices:
- /dev/net/tun
- /dev/kvm
ports:
- '9180:80'
- '9122:22'" > docker-compose.yml
docker-compose up -d
- name: Wait For `curl` to CHR
run: |
echo "Waiting for the HTTP server to start..."
for i in {1..1000}; do
if curl -m 5 -S --fail http://localhost:9180/; then
echo "Server is up!"
exit 0
else
echo "Server not ready yet. Retrying in 10 seconds..."
sleep 10
fi
done
echo "Server did not start within expected time."
exit 1
- name: Test REST API to CHR with curl
run: curl -c 30 -S --fail http://admin@localhost:9180/rest/ip/address
- name: Copy extra-packages packages to CHR
run: |
mkdir extra
cd extra
wget https://download.mikrotik.com/routeros/${{ github.event.inputs.rosver }}/all_packages-x86-${{ github.event.inputs.rosver }}.zip
unzip all_packages*.zip
rm all_packages*.zip
cd ..
scp -o 'StrictHostKeyChecking no' -P 9122 extra/* admin@localhost:/
- name: Reboot CHR to use extra-packages
run: |
# curl -X POST http://admin@localhost:9180/rest/system/reboot --header "Content-Type: application/json"
ssh -p 9122 admin@localhost /system/reboot || true
- name: Setup Bun Runtime
uses: oven-sh/setup-bun@v1
with:
bun-version: 'latest'
- name: Setup NodeJS
uses: actions/setup-node@v4
with:
node-version: 18
- name: 2nd Wait For `curl` to CHR
run: |
echo "Waiting for the HTTP server to start..."
for i in {1..1000}; do
if curl -m 5 -S --fail http://localhost:9180/; then
echo "Server is up!"
exit 0
else
echo "Server not ready yet. Retrying in 10 seconds..."
sleep 10
fi
done
echo "Server did not start within expected time."
exit 1
- name: Get let of pacakges from REST API to CHR with curl
run: curl -c 30 -S --fail http://admin@localhost:9180/rest/system/package | jq '.[] | .name'
- name: Test Bun Connection to RouterOS
id: connection-check
run: |
BUNROSVER=$(bun rest2raml.js --version)
echo "rosver=$BUNROSVER" | xargs >> "$GITHUB_OUTPUT"
- name: Run RAML Generator Code with Bun
run: |
bun install js-yaml raml2html raml2html-slate-theme
bun rest2raml.js ${{ github.event.inputs.start_path }}
./node_modules/.bin/raml2html -v --theme raml2html-slate-theme ros-rest*.raml > index.html
- name: Validate RAML 1.0 using webapi-parse library
run: |
npm install webapi-parser
node validraml.cjs ros-rest*.raml
- name: Convert RAML 1.0 to OAS 2.0 using webapi-parse library
run: |
npm install webapi-parser
node raml2oas.cjs ros-rest*.raml
- name: Move Built File to /docs
id: publish-to-docs
run: |
echo ${{ steps.connection-check.outputs.rosver }}
echo $ROS_FILTER
ROS_FILTER=$(echo ${{ github.event.inputs.start_path }} | tr ' ' '+')
DOCS_PATH=docs/${{ steps.connection-check.outputs.rosver }}/extra/$ROS_FILTER
echo $DOCS_PATH
mkdir -p $DOCS_PATH/docs
cp index.html $DOCS_PATH/docs
cp ros-rest*.raml $DOCS_PATH/schema.raml
cp ros-inspect*.json $DOCS_PATH/inspect.json
cp ros-oas2*.json $DOCS_PATH/oas2.json
# cp ros-oas3*.json $DOCS_PATH/oas3.json
echo "subpath=$ROS_FILTER" >> $GITHUB_OUTPUT
ls -r
- name: Commit and push changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git status
git pull
git add docs/${{ steps.connection-check.outputs.rosver }}/*
git commit -m "Publish ${{ steps.connection-check.outputs.rosver }} ${{ steps.publish-to-docs.outputs.subpath }} [${{ github.workflow }}]"
git push origin main
- name: Save Build Artifacts
uses: actions/upload-artifact@v4
with:
name: build-results
path: |
ros-rest*.raml
ros-inspect*.json
index.html
- name: Cleanup Running Docker
run: docker-compose down