Skip to content

Fetch from wiki & sdvx.in #8

Fetch from wiki & sdvx.in

Fetch from wiki & sdvx.in #8

Workflow file for this run

name: Fetch data from wiki
on:
schedule:
- cron: '0 2 * * THU'
workflow_dispatch:
jobs:
fetch_from_wiki:
name: Fetch from wiki
runs-on: ubuntu-latest
steps:
- name: Set timezone
uses: szenius/[email protected]
with:
timezoneLinux: "Asia/Tokyo"
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Install dependencies
run: |
pip install -r requirements.txt
- name: Run main.py script and capture output
id: run_script
run: |
{
echo "OUTPUT_LOG<<EOF"
python scripts/update-wiki-data.py --nocolors --escape
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Extract datestamp from script output
id: extract_date
run: echo "datestamp=$(cat data/music-ex.json | jq '.[-1].date | tonumber')" >> "$GITHUB_OUTPUT"
- name: Check script output
id: check_script
run: |
if [[ "${{ steps.run_script.outputs.OUTPUT_LOG }}" == *"Updated song extra data from wiki"* ]]; then
echo "Updated song data from wiki. Creating a pull request."
echo "CREATE_PR=true" >> "$GITHUB_OUTPUT"
else
echo "Nothing updated. Skipping pull request creation."
echo "CREATE_PR=false" >> "$GITHUB_OUTPUT"
fi
- name: Configure Git user
if: steps.check_script.outputs.CREATE_PR == 'true'
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
- name: Create new branch and commit changes
if: steps.check_script.outputs.CREATE_PR == 'true'
env:
UNIQUE_STRING: ${{ github.run_id }}-${{ github.run_attempt }}
run: |
git checkout -b apply-wiki-${{ steps.extract_date.outputs.DATESTAMP }}
git add .
git commit -m "[Automated] Apply updated data from wiki ${{ steps.extract_date.outputs.DATESTAMP }}"
git push origin apply-wiki-${{ steps.extract_date.outputs.DATESTAMP }}
- name: Create Pull Request
if: steps.check_script.outputs.CREATE_PR == 'true'
run: |
gh pr create \
-B ${{ github.ref_name }} \
-H "apply-wiki-${{ steps.extract_date.outputs.DATESTAMP }}" \
--title "[Automation] Update website with updated song data (${{ steps.extract_date.outputs.DATESTAMP }})" \
--body "${{ steps.run_script.outputs.OUTPUT_LOG }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}