diff --git a/.github/workflows/keepalive.yml b/.github/workflows/keepalive.yml new file mode 100644 index 0000000..f532c97 --- /dev/null +++ b/.github/workflows/keepalive.yml @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# +# This file is part of Invenio. +# Copyright (C) 2025 CERN. +# +# Invenio is free software; you can redistribute it and/or modify it +# under the terms of the MIT License; see LICENSE file for more details. + +name: Keepalive + +on: + schedule: + - cron: "0 0 1 * *" # Run once a month + workflow_dispatch: + +permissions: + contents: write + +jobs: + keepalive: + name: Keepalive + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + # ensures that crons are not suspended after 45 days + - name: Keepalive check + uses: gautamkrishnar/keepalive-workflow@v2 diff --git a/.github/workflows/sync-lists.yml b/.github/workflows/sync-lists.yml new file mode 100644 index 0000000..3a2ca87 --- /dev/null +++ b/.github/workflows/sync-lists.yml @@ -0,0 +1,66 @@ +# -*- coding: utf-8 -*- +# +# This file is part of Invenio. +# Copyright (C) 2025 CERN. +# +# Invenio is free software; you can redistribute it and/or modify it +# under the terms of the MIT License; see LICENSE file for more details. + +name: Sync and Release + +on: + schedule: + - cron: "0 0 1 * *" # Run once a month + workflow_dispatch: + +permissions: # This permission is needed for the keep-alive and auto-commit actions + contents: write + +jobs: + check-for-changes: + runs-on: ubuntu-latest + outputs: + changes_detected: ${{ steps.diff.outputs.changes_detected }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Run script to update robot and machine lists + run: | + cd scripts/ && python update-lists.py && cd .. + + - name: Check for changes + id: diff + run: | + git diff --quiet counter_robots/data/ || echo "changes_detected=true" >> $GITHUB_ENV + + update-repo: + runs-on: ubuntu-latest + needs: check-for-changes + if: needs.check-for-changes.outputs.changes_detected == 'true' + + steps: + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v5 + with: + file_pattern: 'counter_robots/data/*.txt' + commit_message: Update robots and machines lists + + - name: Update version + run: | + NEW_VERSION=$(date +'%Y.%m') + echo "new_version=$NEW_VERSION" >> $GITHUB_ENV + sed -i 's/^__version__ = .*/__version__ = '"'"$NEW_VERSION"'"'/' counter_robots/version.py + + - name: Push release commit + uses: stefanzweifel/git-auto-commit-action@v5 + with: + file_pattern: 'counter_robots/version.py' + commit_message: 'release: ${{ env.new_version }}' + + - name: Create and push tag + run: | + git fetch --tags + git tag "v${{ env.new_version }}" -a "release: ${{ env.new_version }}" + git push origin "v${{ env.new_version }}"