Run Parse Fyrliste Script and Create PR #39
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: Run Parse Fyrliste Script and Create PR | |
on: | |
schedule: | |
- cron: "0 0 * * 0" # Runs weekly at midnight UTC on Sunday | |
workflow_dispatch: # Allows manual triggering | |
jobs: | |
generate-and-pr: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Check out the repository | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # Needed for creating branches | |
ref: main | |
# Step 2: Set up Python | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.11" | |
# Step 3: Install dependencies (if any) | |
- name: Install Dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r scripts/requirements.txt # If you have dependencies | |
# Step 4: Run the Python script | |
- name: Run Script | |
run: | | |
python scripts/parse.py | |
- name: Run Data Quality Check | |
run: | | |
python scripts/check_data_quality.py > quality_report.md | |
# Step 5: Configure Git | |
- name: Configure Git | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
# Step 6: Check for changes and commit | |
- name: Commit Changes | |
id: commit_changes | |
run: | | |
git add lighthouses.qml scripts/lighthouses.json scripts/lighthouses_with_problems.csv | |
if git diff --cached --quiet; then | |
echo "No changes to commit." | |
echo "::set-output name=changes::false" | |
else | |
git commit -m "Update generated files [skip ci]" | |
echo "::set-output name=changes::true" | |
fi | |
- name: Store build timestamp | |
run: echo "BUILD_TIME=$(date +'%Y-%m-%d')" >> $GITHUB_ENV | |
- name: Read Quality Report | |
id: quality_report | |
run: | | |
echo "REPORT<<EOF" >> $GITHUB_ENV | |
cat quality_report.md >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
# Step 7: Create Pull Request if there are changes | |
- name: Create Pull Request | |
id: create_pr | |
if: steps.commit_changes.outputs.changes == 'true' | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
commit-message: Added quality report | |
branch: update-fyrliste-${{ github.run_number }} | |
title: "Updated Fyrliste to ${{ env.BUILD_TIME }}" | |
body: | | |
${{ env.REPORT }} | |
[View full list of problematic lighthouses](https://github.com/${{ github.repository }}/blob/update-fyrliste-${{ github.run_number }}/scripts/lighthouses_with_problems.csv) | |
labels: automated-pr | |
base: main |