---
# This action is centrally managed in https://github.com/<organization>/.github/
# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in
# the above-mentioned repo.

# This workflow is designed to work with the following workflows:
# - automerge
# - autoupdate-labeler

# It uses an action that auto-updates pull requests branches, when changes are pushed to their destination branch.
# Auto-updating to the latest destination branch works only in the context of upstream repo and not forks.
# Dependabot PRs are updated by an action that comments `@depdenabot rebase` on dependabot PRs. (disabled)

name: autoupdate

on:
  push:
    branches:
      - 'nightly'

jobs:
  autoupdate:
    name: Autoupdate autoapproved PR created in the upstream
    if: startsWith(github.repository, 'LizardByte/')
    runs-on: ubuntu-latest
    steps:
      - name: Update
        uses: docker://chinthakagodawita/autoupdate-action:v1
        env:
          EXCLUDED_LABELS: "central_dependency,dependencies"
          GITHUB_TOKEN: '${{ secrets.GH_BOT_TOKEN }}'
          PR_FILTER: "labelled"
          PR_LABELS: "autoupdate"
          PR_READY_STATE: "all"
          MERGE_CONFLICT_ACTION: "fail"

# Disabled due to:
# - no major version tag, resulting in constant nagging to update this action
# - additionally, the code is sketchy, 16k+ lines of code?
# https://github.com/bbeesley/gha-auto-dependabot-rebase/blob/main/dist/main.cjs
#
#  dependabot-rebase:
#    name: Dependabot Rebase
#    if: >-
#      startsWith(github.repository, 'LizardByte/')
#    runs-on: ubuntu-latest
#    steps:
#      - name: rebase
#        uses: "bbeesley/gha-auto-dependabot-rebase@v1.3.18"
#        env:
#          GITHUB_TOKEN: ${{ secrets.GH_BOT_TOKEN }}
