# Generated by `sfdt ci init --provider github --type monitor --runner action`.
# Scheduled org monitoring via the SFDT action ({{actionRef}}): the action
# installs a pinned CLI and authenticates the org, then runs all checks, takes
# a metadata backup, and pushes the snapshot to configured channels.
#
# Required repository secrets (Settings > Secrets and variables > Actions):
{{authSecretsDoc}}
#   SLACK_WEBHOOK_URL    (optional) Slack incoming webhook
#   TEAMS_WEBHOOK_URL    (optional) Microsoft Teams incoming webhook
name: SFDT Org Monitoring
on:
  schedule:
    - cron: '{{cron}}'
  workflow_dispatch: {}
permissions:
  contents: read
jobs:
  monitor:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Run org monitoring
        uses: {{actionRef}}
        with:
          args-json: '["monitor","all","--org","{{org}}","--backup","--notify","--json"]'
          auth-method: {{authMethod}}
          org-alias: {{org}}
          node-version: '{{nodeVersion}}'
          {{authInputs}}
        env:
          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
          TEAMS_WEBHOOK_URL: ${{ secrets.TEAMS_WEBHOOK_URL }}
      - name: Upload monitoring snapshot
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: sfdt-monitor-snapshot
          path: logs/monitor-latest.json
          if-no-files-found: ignore
