From 858bb76605eb272d40f1db4d8aab18132e69ffb4 Mon Sep 17 00:00:00 2001 From: Camille Frantz Date: Tue, 8 Jul 2025 10:11:13 -0500 Subject: [PATCH] puppybot workflow --- .gitea/workflows/puppies.yaml | 28 ++++++++++++++++++++++++++++ puppies.py | 8 ++++---- 2 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 .gitea/workflows/puppies.yaml diff --git a/.gitea/workflows/puppies.yaml b/.gitea/workflows/puppies.yaml new file mode 100644 index 0000000..29e80a7 --- /dev/null +++ b/.gitea/workflows/puppies.yaml @@ -0,0 +1,28 @@ +name: PuppyBot +on: + schedule: + - cron: '23 */4 * * *' + workflow_dispatch: + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Python + uses: actions/setup-python@v3 + with: + python-version: "3.13" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Run puppies.py + run: + python puppies.py + env: + BOTS_PUPPYBOT_TOKEN: ${{ secrets.BOTS_PUPPYBOT_TOKEN }} + BOTS_ENDPOINT: ${{ secrets.BOTS_ENDPOINT }} + PUSHOVER_ENDPOINT: ${{ secrets.PUSHOVER_ENDPOINT }} + PUSHOVER_USER_TOKEN: ${{ secrets.PUSHOVER_USER_TOKEN }} + PUSHOVER_BOTS_TOKEN: ${{ secrets.PUSHOVER_BOTS_TOKEN }} diff --git a/puppies.py b/puppies.py index 2be43d4..df27a58 100644 --- a/puppies.py +++ b/puppies.py @@ -22,10 +22,10 @@ if unsplash_result.reason == 'OK': status_record = {'spoiler_text': 'Random puppy image courtesy of Unplash.com', 'status': f"{picture_details.description or picture_details.alt_description}\n\n{puppy_tags}", 'visibility': 'public', 'media_ids[]': [uploaded.id]} post_result = post(post_endpoint, headers=puppy_hdr, data=status_record) if post_result.reason == 'OK': - print(loads(post_result.text)['url']) + notify(-1, 'puppybot: ' + loads(post_result.text)['url']) else: - print('Something went wrong; ' + post_result.reason) + notify(0, 'Status update did not go through; ' + post_result.reason) else: - print('Upload did not go thru; ' + upload_result.reason) + notify(0, 'Upload did not go through; ' + upload_result.reason) else: - print('Unsplash api not cooperating; ' + unsplash_result.reason) + notify(0, 'Unsplash api call did not go through; ' + unsplash_result.reason)