Files
wutheringwaves/.gitea/workflows/main.yml
Joakim Hellsén b5a1e8c593
All checks were successful
Run Scraper / scrape (push) Successful in 22s
Refactor GitHub Actions workflow
2025-06-12 04:10:34 +02:00

74 lines
2.3 KiB
YAML

name: Run Scraper
on:
schedule:
- cron: '0 * * * *' # Every hour
workflow_dispatch:
push:
paths:
- 'scrape.py'
- '.gitea/workflows/main.yml'
jobs:
scrape:
runs-on: ubuntu-latest
steps:
- name: Check for required secret
run: |
if [ -z "${{ secrets.REPO_WRITE_PAT }}" ]; then
echo "Missing REPO_WRITE_PAT secret. Aborting."
exit 1
fi
- name: Checkout code
uses: https://github.com/actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: https://github.com/actions/setup-python@v5
with:
python-version: '3.13'
- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Install dependencies
run: uv sync
- name: Run script
run: uv run python scrape.py
- name: Stage any changes from scraper
run: |
git add -A
- name: Pull latest changes with rebase
run: |
git config user.name "Joakim Hellsén"
git config user.email "tlovinator@gmail.com"
# If there are staged changes, commit them temporarily
if ! git diff --cached --quiet; then
git commit -m "Temporary commit for rebase"
git pull --rebase https://${{ secrets.REPO_WRITE_PAT }}@git.lovinator.space/TheLovinator/wutheringwaves.git master
# Reset to unstage the temporary commit but keep the changes
git reset --soft HEAD~1
else
git pull --rebase https://${{ secrets.REPO_WRITE_PAT }}@git.lovinator.space/TheLovinator/wutheringwaves.git master
fi
- name: Get the files that will be committed
id: get_modified_files
run: |
files=$(git diff --cached --name-only | xargs | sed 's/ /, /g')
echo "files=$files" >> $GITHUB_OUTPUT
- name: Commit and push changes
run: |
# Check if there are any staged changes
if git diff --cached --quiet; then
echo "No changes to commit"
else
git commit -m "Updated files: ${{ steps.get_modified_files.outputs.files }}"
git push https://${{ secrets.REPO_WRITE_PAT }}@git.lovinator.space/TheLovinator/wutheringwaves.git HEAD:master
fi