Update Omada SDN URL #73
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: Update Omada SDN URL | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 2 * * 2,6" | |
jobs: | |
update_dependencies: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out codebase | |
uses: actions/checkout@v4 | |
- name: Get latest Omada SDN URL | |
id: omada_url | |
run: | | |
URL="https://www.tp-link.com/us/support/download/omada-software-controller/" | |
TARGET="https://static.tp-link.com/upload/software/.*.gz" | |
latest_url=$(curl -s $URL | grep -om1 "${TARGET}") | |
latest_version=$(echo $latest_url | grep -o "[0-9]\.[0-9]\.[0-9][0-9]\?") | |
echo "latest_url=$latest_url" >>$GITHUB_OUTPUT | |
echo "latest_version=$latest_version" >>$GITHUB_OUTPUT | |
current_url=$(<omada.url) | |
current_version=$(grep -o "[0-9]\.[0-9]\.[0-9][0-9]\?" omada.url) | |
echo "current_url=$current_url" >>$GITHUB_OUTPUT | |
echo "current_version=$current_version" >>$GITHUB_OUTPUT | |
# check if semver is <= | |
ver_lte() { | |
[ "$1" = "$(echo -e "$1\n$2" | sort -V | head -n1)" ] | |
} | |
if [ ver_lte $current_version $latest_version ]; then | |
echo "version is outdated" | |
update_version_file=true | |
else | |
echo "version is latest" | |
update_version_file=false | |
fi | |
echo "UPDATE_VERSION_FILE="$update_version_file"" >>$GITHUB_ENV | |
- name: Update Omada SDN URL | |
if: env.UPDATE_VERSION_FILE | |
env: | |
LATEST_URL: ${{ steps.omada_url.outputs.latest_url }} | |
run: | | |
# update default vars | |
sed -i "s|^omada_tar_src:.*$|omada_tar_src: $LATEST_URL|" ./defaults/main.yml | |
# update 'omada.url' file | |
echo ${{ steps.omada_url.outputs.latest_url }} > omada.url | |
- name: Create pull request | |
if: env.UPDATE_VERSION_FILE | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
commit-message: update omada version to ${{ steps.omada_url.outputs.latest_version }} | |
title: update omada version to ${{ steps.omada_url.outputs.latest_version }} | |
body: | | |
Updates [Omada SDN][1] ${{ steps.omada_url.outputs.current_version }} to ${{ steps.omada_url.outputs.latest_version }} | |
Default URL changed to ${{ steps.omada_url.outputs.latest_url }} | |
Auto-generated by [create-pull-request][2] | |
[1]: https://www.tp-link.com/us/support/download/omada-software-controller/ | |
[2]: https://github.com/peter-evans/create-pull-request | |
labels: dependencies, status/auto-created | |
branch: update-omada-url |