Skip to content

Check for update on Mikrotik website and generate a PR if necessary #132

Check for update on Mikrotik website and generate a PR if necessary

Check for update on Mikrotik website and generate a PR if necessary #132

Workflow file for this run

name: "Check for update on Mikrotik website and generate a PR if necessary"
on:
workflow_dispatch:
schedule:
- cron: "0 4 * * *"
jobs:
routeros:
name: "Build & Test images"
runs-on: "ubuntu-latest"
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: '1'
- name: Check new release
id: check_release
run: |
LAST_MIKROTIK_RELEASE=$( curl https://mikrotik.com/download/archive -o - 2>/dev/null | grep -o '<a href=['"'"'"][^"'"'"']*['"'"'"]' | sed -e 's/^<a href=["'"'"']//' -e 's/["'"'"']$//' | grep -i c-stable | sed -r 's/\#c-stable-v//gi'|sed -r 's/_/\./gi'|sort -V|tail -n 1)
NEW_TAG=$(grep "ROUTEROS_VERSION=\"" Dockerfile |cut -d "\"" -f 2)
if [ "$LAST_MIKROTIK_RELEASE" != "$NEW_TAG" ]; then
echo "New version found: $LAST_MIKROTIK_RELEASE"
echo "Current version: $NEW_TAG"
echo "release=$LAST_MIKROTIK_RELEASE" > "$GITHUB_OUTPUT"
echo "new=true" >> "$GITHUB_OUTPUT"
else
echo "No new version found"
echo "new=false" >> "$GITHUB_OUTPUT"
fi
- name: Edit Dockerfile
if: ${{ steps.check_release.outputs.new == 'true' }}
run: |
sed -r "s/(ROUTEROS_VERSION=\")(.*)(\")/\1${{ steps.check_release.outputs.release }}\3/g" -i Dockerfile
git diff
- name: Create Pull Request
if: ${{ steps.check_release.outputs.new == 'true' && !env.ACT }}
uses: peter-evans/create-pull-request@v6
with:
commit-message: "Update RouterOS version to ${{ steps.check_release.outputs.release }}"
committer: "GitHub Actions<[email protected]>"
body: 'Created by Github action'
title: 'Update RouterOS version to ${{ steps.check_release.outputs.release }}'
branch: update-routeros