manual-using-docker-in-docker #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: manual-using-docker-in-docker | |
on: | |
workflow_dispatch: | |
inputs: | |
rosver: | |
description: 'Tag for RouterOS Docker Image (latest)' | |
required: true | |
default: "latest" | |
start_path: | |
description: 'Starting path (space seperated)' | |
required: false | |
jobs: | |
job-using-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 Compose | |
uses: docker/setup-buildx-action@v1 | |
- 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: | | |
echo "version: '3' | |
services: | |
routeros: | |
image: evilfreelancer/docker-routeros:${{ github.event.inputs.rosver }} | |
restart: unless-stopped | |
cap_add: | |
- NET_ADMIN | |
devices: | |
- /dev/net/tun | |
- /dev/kvm | |
ports: | |
- 9180:80" > docker-compose.yml | |
docker-compose up -d | |
- name: Wait For `curl` | |
run: | | |
echo "Waiting for the HTTP server to start..." | |
for i in {1..1000}; do | |
if curl -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 HTTP Server with curl | |
run: curl -S --fail http://admin@localhost:9180/rest/ip/address | |
- name: Setup Bun Runtime | |
uses: oven-sh/setup-bun@v1 | |
with: | |
bun-version: 'latest' | |
- name: Test Bun Connection to RouterOS | |
id: connection-check | |
run: | | |
ROUTEROS_VER=$(bun rest2raml.js --version) | |
echo $ROUTEROS_VER | |
##echo "::set-output name=rosver::$ROUTEROS_VER" | |
echo "rosver=$ROUTEROS_VER" >> $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 }} | |
find . -name raml2html | |
./node_modules/.bin/raml2html --theme raml2html-slate-theme ros-rest*.raml > ros-rest-generated.html | |
- 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 }}/$ROS_FILTER | |
echo $DOCS_PATH | |
mkdir -p $DOCS_PATH | |
cp ros-* $DOCS_PATH | |
echo "subpath=$ROS_FILTER" >> $GITHUB_OUTPUT | |
ls -r | |
- name: Commit and push changes | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git status | |
git add docs/${{ steps.connection-check.outputs.rosver }}/* | |
git commit -m "Publish ${{ steps.connection-check.outputs.rosver }} ${{ steps.publish-to-docs.outputs.subpath }} to Web" | |
git push origin main | |
- name: Save Build Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-results | |
path: | | |
ros-rest* | |
ros-inspect* | |
ros-rest-generated* | |
- name: Cleanup Running Docker | |
run: docker-compose down |