puppybot workflow
This commit is contained in:
28
.gitea/workflows/puppies.yaml
Normal file
28
.gitea/workflows/puppies.yaml
Normal file
@ -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 }}
|
@ -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)
|
||||
|
Reference in New Issue
Block a user