Added data quality measurement and updated workflow to print status #25
Workflow file for this run
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 | |
pull_request: | |
branches: | |
- main | |
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.txt | |
# 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 | |
# 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: Update generated files | |
branch: update-fyrliste-${{ github.run_number }} | |
title: "Updated Fyrliste to ${{ env.BUILD_TIME }}" | |
body: | | |
This PR updates the generated files based on the latest run. | |
labels: automated-pr | |
# You can specify the base branch if different from the default | |
base: anders/test-dq | |
# Step 8: Add quality report as PR comment | |
- name: Read Quality Report | |
id: quality_report | |
run: | | |
echo "REPORT<<EOF" >> $GITHUB_ENV | |
cat quality_report.txt >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- name: Comment on PR with Quality Report | |
if: steps.commit_changes.outputs.changes == 'true' | |
uses: peter-evans/create-or-update-comment@v3 | |
with: | |
issue-number: ${{ steps.create_pr.outputs.pull-request-number }} | |
body: | | |
## Data Quality Report | |
<details> | |
<summary>Click to expand quality report</summary> | |
``` | |
${{ env.REPORT }} | |
``` | |
</details> | |
[View full list of problematic lighthouses](https://github.com/${{ github.repository }}/blob/update-fyrliste-${{ github.run_number }}/scripts/lighthouses_with_problems.csv) | |
token: ${{ secrets.GITHUB_TOKEN }} |