-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
workflows: Add automatic release action on file change
- Loading branch information
1 parent
f751b04
commit 4e1660c
Showing
3 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
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 | ||
with: | ||
ref: keepalive | ||
|
||
# ensures that crons are not suspended after 60 days | ||
- name: Keepalive check | ||
uses: gautamkrishnar/keepalive-workflow@v1 | ||
with: | ||
gh_token: ${{ secrets.INVENIOBOT_PAT }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Monthly Sync | ||
|
||
on: | ||
schedule: | ||
- cron: "0 0 1 * *" # Run once a month | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
check-and-update: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Run script to update robot and machine lists | ||
run: | | ||
cd scripts/ && python update-lists.py && cd .. | ||
- name: Check for changes | ||
run: | | ||
git diff --quiet || echo "changes_detected=true" >> $GITHUB_ENV | ||
continue-on-error: true | ||
|
||
- name: Commit if changes detected | ||
if: env.changes_detected == 'true' | ||
run: | | ||
git config user.name "github-actions[bot]" | ||
git config user.email "github-actions[bot]@users.noreply.github.com" | ||
git add ./counter_robots/data/machine.txt ./counter_robots/data/robot.txt | ||
git commit -m "Update robots and machines lists" | ||
git push | ||
- name: Update version and push release commit | ||
if: env.changes_detected == 'true' | ||
run: | | ||
NEW_VERSION=python bump_version.py | ||
git config user.name "github-actions[bot]" | ||
git config user.email "github-actions[bot]@users.noreply.github.com" | ||
git add version.py | ||
git commit -m "release: $NEW_VERSION" | ||
git push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import datetime | ||
|
||
current_year = datetime.datetime.now().year | ||
version_file = 'version.py' | ||
|
||
with open(version_file, 'r') as file: | ||
try: | ||
content = file.read() | ||
current_version = content.split('__version__ = ')[1][1:-1] | ||
except FileNotFoundError: | ||
current_version = '2018.6' | ||
|
||
major, minor = map(int, current_version.split('.')) | ||
new_version = f'{major}.{minor + 1}\n' | ||
|
||
with open(version_file, 'w') as file: | ||
file.write(f"""# -*- coding: utf-8 -*- | ||
# | ||
# This file is part of COUNTER-Robots. | ||
# Copyright (C) {current_year} CERN. | ||
# | ||
# COUNTER-Robots is free software; you can redistribute it and/or modify it | ||
# under the terms of the MIT License; see LICENSE file for more details. | ||
\"\"\"Version information for COUNTER-Robots. | ||
This file is imported by ``counter_robots.__init__``, | ||
and parsed by ``setup.py``. | ||
\"\"\" | ||
from __future__ import absolute_import, print_function | ||
__version__ = '{new_version}' | ||
""") | ||
|
||
print(new_version) |