Skip to content

Post Image to Bluesky #1583

Post Image to Bluesky

Post Image to Bluesky #1583

Workflow file for this run

name: Post Image to Bluesky
on:
schedule:
# Run every hour
- cron: "0 * * * *"
workflow_dispatch: # Allow manual triggering from GitHub
inputs:
run_reason:
description: 'Reason for manual run'
required: false
jobs:
post_image:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository
- name: Checkout code
uses: actions/checkout@v3
# Step 2: Set up Python
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
# Step 3: Install dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
# Step 4: Run the bot script
- name: Run Bluesky bot
env:
BLUESKY_USERNAME: ${{ secrets.BLUESKY_USERNAME }}
BLUESKY_PASSWORD: ${{ secrets.BLUESKY_PASSWORD }}
run: python bot.py
# Step 5: Debugging and check file status
- name: Debug file status
run: |
echo "Current working directory:"
pwd # Prints the current working directory
echo "Files in 'images' directory:"
ls -l images/ # Lists all files in the 'images' folder
# Step 6: Commit and push the changes to GitHub (after updating the log)
- name: Commit and push the updated log file
run: |
# Set the local Git user information for this repository
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
# Stage all changes (including updated log file)
git add posted_images.log
# Commit the changes with a message
git commit -m "Update posted images log"
# Push the commit to GitHub using the GitHub token for authentication
git push https://github-actions[bot]:${{ secrets.GH_TOKEN }}@github.com/curephoenix/hourlyhibiki-py.git HEAD:main || echo "No changes to push"