Added data quality measurement and updated workflow to print status #21
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: | |
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: anders/test-dq | |
# Step 2: Set up Python | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.11" | |
# Step 3: Install dependencies | |
# - name: Install Dependencies | |
# run: | | |
# python -m pip install --upgrade pip | |
# pip install -r scripts/requirements.txt | |
# Step 4: Run the Python script | |
# - name: Run Script | |
# run: | | |
# python scripts/parse.py | |
# Step 5: Upload the data quality report to the repository | |
- name: Upload Data Quality Report | |
run: | | |
BASE64_CONTENT=$(base64 lighthouses_with_problems.csv) | |
gh api \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
/repos/${{ github.repository }}/contents/lighthouses_with_problems.csv \ | |
-f message="Upload lighthouses_with_problems.csv" \ | |
-F content="$BASE64_CONTENT" \ | |
-F branch="main" | |
# Step 6: 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 7: Check for changes and commit | |
- name: Commit Changes | |
id: commit_changes | |
run: | | |
git add . | |
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 | |
# Step 8: Create Pull Request if there are changes | |
- name: Create Pull Request | |
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 | |
base: main | |
# Step 9: Comment on PR with a link to the uploaded file | |
- name: Comment on PR with File Link | |
if: steps.commit_changes.outputs.changes == 'true' | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const prNumber = context.payload.pull_request.number; | |
const fileUrl = `https://raw.githubusercontent.com/${context.repo.owner}/${context.repo.repo}/main/lighthouses_with_problems.csv`; | |
await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: prNumber, | |
body: `### Data Quality Report\n\nThe data quality report is available [here](${fileUrl}).` | |
}); |