Wikipedia - Fetch Current events
content
#32017
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Wikipedia - Fetch `Current events` content | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '09,39 * * * *' | |
push: | |
branches: | |
- main | |
paths: | |
- '.github/scripts/*.py' | |
- '.github/workflows/*.yml' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install pytest requests bleach | |
- name: Run tests | |
run: pytest .github/scripts/test_fetch_current_events.py | |
- name: Run fetch script | |
run: python .github/scripts/fetch_current_events.py | |
- name: Update content file and version | |
if: env.CHANGE == 'true' | |
shell: bash | |
run: | | |
echo "updating content file" | |
mv tmp_content.js content.js | |
echo "updating content version" | |
sed -i 's/content.js?v=[0-9]*/content\.js\?v='"$(date '+%Y%m%d%H%M%S')"'/g' index.html | |
- name: Commit & Push | |
if: env.CHANGE == 'true' | |
uses: Andro999b/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: main | |
force: true | |
message: 'update news content' |