Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workflows: Add automatic release action on file change #13

Merged
merged 4 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/keepalive.yml
Original file line number Diff line number Diff line change
@@ -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
66 changes: 66 additions & 0 deletions .github/workflows/sync-lists.yml
Original file line number Diff line number Diff line change
@@ -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 }}"
Loading