name: Flatpak dependency updates
on:
  schedule: # for scheduling to work this file must be in the default branch
  - cron: "0 0 * * *" # run every day
  workflow_dispatch: # can be manually dispatched under GitHub's "Actions" tab 

jobs:
  flatpak-external-data-checker:
    runs-on: ubuntu-24.04

    steps:
      - uses: actions/checkout@v6.0.2
        with:
          # we can't push changes to a fork via a shallow update, we need to clone the full repo
          fetch-depth: 0
          # by default when persisting credentials the local git config will use the workflow provided GITHUB_TOKEN, not our own GITHUB_TOKEN env var for the container
          # we must not use the provided GITHUB_TOKEN, as it will fail to push to the fork since the provided GITHUB_TOKEN is only for the repository where the workflow is running 
          persist-credentials: false

      - uses: docker://ghcr.io/flathub/flatpak-external-data-checker:latest
        env:
          GIT_AUTHOR_NAME: EasyEffects Bot
          GIT_COMMITTER_NAME: EasyEffects Bot
          # email sets "EasyEffects Bot" user as commit author
          GIT_AUTHOR_EMAIL: 110548574+easyeffects-bot@users.noreply.github.com
          GIT_COMMITTER_EMAIL: 110548574+easyeffects-bot@users.noreply.github.com
          EMAIL: 110548574+easyeffects-bot@users.noreply.github.com
          GITHUB_TOKEN: ${{ secrets.EASYEFFECTS_BOT }}
        with:
          entrypoint: /bin/bash
          args: -c "git config --global --add safe.directory /github/workspace && cd /github/workspace && /app/flatpak-external-data-checker --update --always-fork util/flatpak/com.github.wwmm.easyeffects.Devel.json"
