Check for update on Mikrotik website and generate a PR if necessary #327
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: "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@v7 | |
with: | |
commit-message: "Update RouterOS version to ${{ steps.check_release.outputs.release }}" | |
committer: "GitHub Actions<github-actions@users.noreply.github.com>" | |
body: 'Created by Github action' | |
title: 'Update RouterOS version to ${{ steps.check_release.outputs.release }}' | |
branch: update-routeros |