SPB Git

Repository Public License

09-website-change-monitor.yaml 5.7 KB 145 lines yaml

1# =============================================================================2# SP BOUCHER | SOURCE FILE3# =============================================================================4# Project      : ORIX OS Automation5# File         : Workflows/Examples/09-website-change-monitor.yaml6# Author       : Simon-Pierre Boucher | https://spboucher.ai7# Contact      : support@spboucher.ai8# Copyright    : (c) 2026 Simon-Pierre Boucher9# License      : Proprietary, all rights reserved (see license file)10# =============================================================================11# END OF SP BOUCHER SOURCE HEADER12# =============================================================================1314# ORIX OS Automation15# File: Workflows/Examples/09-website-change-monitor.yaml16# Description: Built-in automation: fetches one page from one approved host, compares it with the previous copy and alerts on a change.17#18# Author: Simon-Pierre Boucher19# Contact: contact@spboucher.ai20#21# Limitations22# - Only the host named by the `host` parameter may be contacted: it is the declared network permission. A `url` on23#   another host is not covered by the accepted permission and waits for approval instead of being fetched.24# - HTTPS only; plain http is accepted for this Mac's loopback addresses (localhost, 127.0.0.1), which is how the25#   example is tested. Redirects to another host are followed by the tool only inside its own rules.26# - One plain GET per run, no login, no JavaScript: pages rendered client-side or behind authentication are not supported.27# - "Changed" is a byte comparison of the saved response body with the previous one: rotating ads, timestamps or tokens28#   count as changes. Bodies larger than 2 MB are truncated before the comparison.29# - Respect the site's terms and robots policy; the default interval is one hour on purpose.30# - The page body is untrusted content: it is stored and compared, never interpreted.31# - The GET is retried (retry.force) because repeating it has no side effect.32# - The alert is a notification: it needs the ORIX app (a command-line run has no application bundle). There the alert33#   step fails by itself, the run ends PARTIALLY_SUCCEEDED and the `changed` output still says what happened.34apiVersion: orix.ai/v135kind: Automation36metadata:37  id: website-change-monitor38  name: Website change monitoring39  description: >-40    Fetches one web page from an approved host every hour, keeps the last copy in a state folder, compares41    the new body with the previous one and posts a notification when it differs.42  tags: [web, monitor, http, schedule]43spec:44  triggers:45    - type: interval46      seconds: 360047    - type: manual48  parameters:49    - name: host50      type: string51      default: example.com52      description: The only host this workflow may contact; it is the declared network permission.53    - name: url54      type: string55      default: https://${{ params.host }}/56      description: Page to watch, on that host.57    - name: stateFolder58      type: path59      default: ~/ORIX Samples/website-change-monitor/State60      description: Folder that keeps current.html and previous.html.61  permissions:62    filesystem:63      read: ["${{ params.stateFolder }}"]64      write: ["${{ params.stateFolder }}"]65    network: ["${{ params.host }}"]66    notifications: true67  budget:68    maxDurationSeconds: 18069    maxToolCalls: 2070  steps:71    - id: prepare72      tool: filesystem.mkdir73      with:74        path: ${{ params.stateFolder }}75    - id: fetch76      name: Fetch the page77      tool: http.request78      with:79        url: ${{ params.url }}80        method: GET81        timeoutSeconds: 3082        maxBytes: 200000083      retry: {maxAttempts: 3, backoffSeconds: 5, backoffMultiplier: 2, force: true}84    - id: saveCurrent85      needs: [prepare, fetch]86      tool: filesystem.write87      with:88        path: ${{ params.stateFolder }}/current.html89        content: ${{ default(steps.fetch.output.body, "") }}90        overwrite: true91    - id: findPrevious92      name: Is there a previous copy?93      needs: [prepare]94      tool: filesystem.search95      with:96        path: ${{ params.stateFolder }}97        pattern: previous.html98        maxDepth: 199    - id: compare100      name: Compare with the previous copy (when there is one)101      needs: [findPrevious, saveCurrent]102      foreach: ${{ steps.findPrevious.output.matches }}103      as: previous104      collect: diff105      steps:106        - id: diff107          tool: filesystem.compare108          with:109            source: ${{ previous.path }}110            destination: ${{ params.stateFolder }}/current.html111    - id: changed112      needs: [compare]113      transform: ${{ steps.compare.output.count > 0 && !first(steps.compare.output.results).identical }}114    - id: promote115      name: The new copy becomes the reference116      needs: [compare]117      tool: filesystem.copy118      with:119        source: ${{ params.stateFolder }}/current.html120        destination: ${{ params.stateFolder }}/previous.html121        overwrite: true122    - id: check123      needs: [saveCurrent, promote]124      verify:125        - equals: ["${{ steps.fetch.output.status }}", 200]126        - fileNonEmpty: ${{ params.stateFolder }}/current.html127        - fileNonEmpty: ${{ params.stateFolder }}/previous.html128    - id: result129      needs: [check, changed]130      output:131        url: ${{ params.url }}132        status: ${{ steps.fetch.output.status }}133        firstRun: ${{ steps.compare.output.count == 0 }}134        changed: ${{ steps.changed.output }}135        sha256: ${{ steps.saveCurrent.output.sha256 }}136    - id: onChange137      name: Did the page change?138      needs: [result]139      if: ${{ steps.changed.output }}140      then: [alert]141    - id: alert142      notify: ${{ params.url }} changed since the last check.143      title: Website change144      continueOnError: true145
Files main
Menu

Theme