outcome text cleaned #4
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
# Workflow runs the scrape process to refresh/update daily | ||
# Run events | ||
on: | ||
# On push | ||
push: | ||
branches: ["main"] | ||
On pull | ||
pull_request: | ||
branches: ["main"] | ||
Add manual trigger from Actions tab | ||
workflow_dispatch: | ||
# Schedule run at 9 AM UTC every day | ||
schedule: | ||
- cron: '0 9 * * *' | ||
# Sets permissions of the GITHUB_TOKEN for deployment to GitHub Pages | ||
permissions: | ||
contents: write # changed from read to allow repo updates | ||
pages: write | ||
id-token: write | ||
# Define workflow job | ||
jobs: | ||
build: | ||
# Runs on the latest version of Ubuntu | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Checks out a copy of repo | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
# Set up Python | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.x' | ||
# Show Current Directory and List Files | ||
- name: Show Current Directory | ||
run: | | ||
echo "Current directory: $(pwd)" | ||
echo "Listing files:" | ||
ls -la | ||
# Install dependencies | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
# Ensure Script is Executable | ||
- name: Ensure Script is Executable | ||
run: chmod +x ofsted_childrens_services_inspection_scrape.py | ||
# Run the scrape | ||
- name: Run Python script | ||
run: | | ||
echo "Running scrape script" | ||
python ofsted_childrens_services_inspection_scrape.py | ||
# Configure Git and Commit changes | ||
- name: Commit and Push changes | ||
# if: github.event_name == 'schedule' # Use on testing, to avoid inf loop for on push workflow event trigger | ||
run: | | ||
git config --local user.email "action@github.com" | ||
git config --local user.name "GitHub Action" | ||
git add index.html | ||
git commit -m "Update index.html via workflow" || echo "No changes to commit" | ||
git push | ||
# Deploy job | ||
deploy: | ||
# Run on the latest version of Ubuntu | ||
runs-on: ubuntu-latest | ||
# Build job must complete successfully | ||
needs: build | ||
steps: | ||
# Deploy to GitHub Pages | ||
- name: Deploy | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
# Directory deployed to GitHub Pages | ||
publish_dir: ./ |