Skip to content

Commit

Permalink
ci: add action to parse schedules every hour
Browse files Browse the repository at this point in the history
  • Loading branch information
dantetemplar committed Sep 19, 2024
1 parent 70f34d9 commit 89b1572
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
47 changes: 47 additions & 0 deletions .github/workflows/parse-schedules.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: "Parse schedules πŸ•΅οΈβ€β™‚οΈ"
on:
schedule:
- cron: '0 * * * *'
workflow_dispatch:

jobs:
check:
name: "Parse schedules πŸ•΅οΈβ€"
runs-on: ubuntu-latest
if: ${{ needs.check.outputs.updated == 'true' }}
steps:
- name: "Check out repository 🚚"
uses: actions/checkout@v4
- name: "Pull the latest changes πŸ”„"
run: git pull
- name: "Set up Python 🐍"
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: "Install Poetry πŸ“¦ (cache-hit)"
id: cached-poetry
uses: actions/cache@v4
with:
path: ~/.local # the path depends on the OS
key: poetry-1.8.3 # increment to reset cache
- name: "Install Poetry πŸ“¦"
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: '1.8.3'
virtualenvs-create: true
virtualenvs-in-project: true
- name: "Install Poetry dependencies πŸ“¦ (cache-hit)"
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-test-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: "Install Poetry dependencies πŸ“¦"
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --with dev
- name: "Parse schedules πŸ•΅οΈβ€β™‚οΈ"
env:
PARSER_AUTH_KEY: ${{ secrets.PARSER_AUTH_KEY }}
INNOHASSLE_API_URL: "https://api.innohassle.ru/events/v0"
run: poetry run python -m src
4 changes: 3 additions & 1 deletion src/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ def main():

parser = argparse.ArgumentParser()

parser.add_argument("--period", type=int, help="Period in seconds", default=600)
parser.add_argument("--period", type=int, help="Period in seconds", default=-1)

args = parser.parse_args()
logger.info(f"Update schedule of Core Courses, Electives and Sports every {args.period} seconds")

while True:
main()
logger.info(f"Wait for {args.period} seconds...")
if args.period == -1:
break
time.sleep(args.period)

0 comments on commit 89b1572

Please sign in to comment.