# This file is part of BOINC.
# https://boinc.berkeley.edu
# Copyright (C) 2025 University of California
#
# BOINC is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
#
# BOINC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with BOINC.  If not, see <http://www.gnu.org/licenses/>.

name: Update Actions
on:
  schedule:
    - cron:  '0 0 * * 0'

env:
  ACTIONS_UPDATE_TOKEN: ${{ secrets.ACTIONS_UPDATE_TOKEN }}

jobs:
  build:
    if: github.repository == 'BOINC/boinc'
    name: ${{ matrix.type }}
    runs-on: ubuntu-latest
    strategy:
      matrix:
        type: [update_actions]
      fail-fast: false
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
        with:
          fetch-depth: 2
      - name: Update actions
        if: success()
        run: |
          python ./ci_tools/update_actions.py ${ACTIONS_UPDATE_TOKEN}
      - name: Check file was updated
        if: success()
        run: |
          set -e
          git diff --exit-code
      - name: Prepare patch file
        if: failure()
        run: |
          git diff > update_actions.patch
      - name: Upload patch
        if: failure()
        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
        with:
          name: update_actions.patch
          path: update_actions.patch
