Skip to content

Check for broken links and sync definitions #188

Check for broken links and sync definitions

Check for broken links and sync definitions #188

name: Check for broken links and sync YAML
on:
# Run daily at 9:00 AM
schedule:
- cron: '0 9 * * *'
# Run on PRs to main
pull_request:
branches: [ main ]
# Allow manual triggering
workflow_dispatch:
jobs:
check-links:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Link Checker
id: lychee
uses: lycheeverse/lychee-action@v1.5.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# Target specific files and improve the arguments
args: >-
--verbose
--no-progress
--exclude-mail
--exclude-loopback
--exclude "file:///.*/issues.*"
--exclude "file:///home/runner/work/.*"
--exclude "https://rijksportaal.overheid-i.nl/.*"
'**/*.yaml'
'**/*.md'
'**/*.ts'
'**/*.vue'
# Output file for creating issues
output: ./lychee/out.md
# Fail if any link is broken
fail: true
# Only create an issue when broken links are found AND running on schedule/manual
- name: Create Issue (Only on schedule or manual run)
if: ${{ failure() && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }}
uses: peter-evans/create-issue-from-file@v4
with:
title: Broken links detected
content-filepath: ./lychee/out.md
labels: broken-links
sync-yaml:
runs-on: ubuntu-latest
# Allow this job to continue even if the check-links job fails
needs: check-links
if: always()
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download YAML file
run: |
curl -s https://modellen.jenvgegevens.nl/dpia/begrippenkader-dpia.yaml -o sources/begrippenkader-dpia.yaml
- name: Check for changes
id: git-check
run: |
git add sources/begrippenkader-dpia.yaml
if ! git diff --staged --quiet; then
echo "changes=true" >> $GITHUB_ENV
else
echo "changes=false" >> $GITHUB_ENV
fi
- name: Commit directly (when in PR)
if: env.changes == 'true' && github.event_name == 'pull_request'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -m "Auto-sync YAML file from external source"
git push
- name: Create Pull Request (when scheduled or manual)
if: env.changes == 'true' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
uses: peter-evans/create-pull-request@v5
with:
base: main
commit-message: "Auto-sync YAML file from external source"
title: "Auto-sync YAML file from external source"
body: |
Automated sync of `begrippenkader-dpia.yaml` from external source.
Source: https://modellen.jenvgegevens.nl/dpia/begrippenkader-dpia.yaml
This PR was created automatically by the sync-yaml workflow.
branch: auto-sync-yaml-${{ github.run_number }}
delete-branch: true