euanwm / OpenWeightlifting

Repository that is deployed for the OpenWeightlifting site
https://www.openweightlifting.org
BSD 3-Clause "New" or "Revised" License
31 stars 21 forks source link

Automated Database Updates #271

Closed euanwm closed 8 months ago

euanwm commented 9 months ago

Is your feature request related to a problem? Please describe. Currently, updates to the database are done by using the Makefile which uses the modules within the python_tools folder. Manual updates mean that I often forget and should be done weekly.

Describe the solution you'd like A GitHub Action that utilises Cron to run the Makefile actions once a week and to then open a PR.

ChatGPT has suggested the below:

name: Update Data and Open PR

on:
  schedule:
    - cron: '0 0 * * *'  # Runs the workflow daily at midnight

jobs:
  update-data-open-pr:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v2

      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: '3.x'  # Specify your Python version

      - name: Install dependencies  # If needed
        run: pip install -r requirements.txt  # Adjust as per your requirements

      - name: Run Python script to download data
        run: python your_script.py  # Replace with your script name and arguments

      - name: Create new branch
        run: |
          git checkout -b data-update-branch
          git add .
          git commit -m "Update data $(date +%Y-%m-%d)"
          git push origin data-update-branch

      - name: Open PR to development
        uses: peter-evans/create-pull-request@v3
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          commit-message: "Update data $(date +%Y-%m-%d)"
          branch: data-update-branch
          title: "Data Update $(date +%Y-%m-%d)"
          body: "This PR updates the data."
          labels: "data update"
          base: "development"
euanwm commented 8 months ago

Closed #277