-
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from Bluebugs/master
Modernize and automate maintenance
- Loading branch information
Showing
11 changed files
with
247 additions
and
15 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "docker" # See documentation for possible values | ||
directory: "/" # Location of package manifests | ||
schedule: | ||
interval: "weekly" | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: "Build docker image and push to DockerHub when a tag is pushed" | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
tags: | ||
- "*" | ||
|
||
jobs: | ||
build: | ||
name: "Build images" | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Docker metadata from Git | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: evilfreelancer/docker-routeros | ||
- name: Login to DockerHub | ||
if: ${{ !env.ACT }} | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Build with Docker | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
push: ${{ !env.ACT }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: "Continuous Integration Tests" | ||
|
||
on: | ||
push: | ||
pull_request: | ||
workflow_dispatch: | ||
workflow_call: | ||
|
||
jobs: | ||
test: | ||
name: "Build & Test images" | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Download docker-compose when using act | ||
if: env.ACT | ||
run: | | ||
sudo curl -L "https://github.com/docker/compose/releases/download/v2.24.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | ||
sudo chmod +x /usr/local/bin/docker-compose | ||
- name: Test with Docker | ||
run: | | ||
# start the container | ||
docker-compose -f docker-compose.dist.yml up --build -d routeros-local | ||
# wait for the container to start | ||
sleep 5 | ||
DOCKERID=$(docker ps --format '{{.ID}}.{{.Names}}.{{.Image}}'|grep evilfreelancer/docker-routeros|cut -f 1 -d '.') | ||
echo "Watching $DOCKERID for Mikrotik login..." | ||
while true | ||
do | ||
if docker logs "$DOCKERID" 2>&1|grep 'MikroTik' | ||
then | ||
break | ||
fi | ||
echo "Not found yet, sleeping..." | ||
sleep 5 | ||
done | ||
# display logs | ||
echo "Container logs:" | ||
docker logs "$DOCKERID" | ||
# download resource and check platform is Mikrotik | ||
curl --retry 12 --retry-all-errors -k -u admin: http://127.0.0.1:7777/rest/system/resource | jq .platform |grep -i mikrotik | ||
- name: Stop container | ||
run: docker-compose -f docker-compose.dist.yml down |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: Lint github-action | ||
|
||
on: [ 'pull_request' ] | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Lint | ||
uses: docker://rhysd/actionlint:1.6.26 | ||
with: | ||
args: -color |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
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 vdi | sed 's:.*/::' | sort -V | tail -n 1 | sed -r 's/chr\-(.*)\.vdi/\1/gi'| sed -r 's/\.zip//gi') | ||
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 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: "Tag master with new version of RouterOS when CI pass" | ||
|
||
on: | ||
push: | ||
branches: | ||
- "master" | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: read | ||
|
||
jobs: | ||
call_test: | ||
uses: EvilFreelancer/docker-routeros/.github/workflows/ci.yml@master | ||
|
||
tag: | ||
name: "Add a tag to git" | ||
runs-on: "ubuntu-latest" | ||
needs: call_test | ||
if: always() && needs.call_test.result == 'success' | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: '0' | ||
|
||
- name: Add new tag on git | ||
run: | | ||
NEW_TAG=$(grep 'ROUTEROS_VERSION="' Dockerfile |cut -d '"' -f 2) | ||
git config user.name 'GitHub Actions' | ||
git config user.email '[email protected]' | ||
git tag "$NEW_TAG" | ||
- name: Push new tag to git | ||
if: ${{ !env.ACT }} | ||
run: git push origin "$NEW_TAG" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
/.idea/ | ||
/*.vdi | ||
/docker-compose.yml | ||
/docker-compose.dist.yml |
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
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
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
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