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-20.04

    steps:
      - uses: actions/checkout@v3.3.0
        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:
          args: --update --always-fork util/flatpak/com.github.wwmm.easyeffects.Devel.json
