try to check static feed URLs in changed DMFR files #311
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: Comment on PRs that need DMFR formatting changes | |
on: | |
pull_request: | |
paths: | |
- '**.dmfr.json' | |
permissions: | |
issues: write | |
pull-requests: write | |
jobs: | |
format: | |
if: github.ref != 'refs/heads/main' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.event.pull_request.head.sha }} | |
repository: ${{github.event.pull_request.head.repo.full_name}} | |
- name: Install transitland-lib | |
run: scripts/install-transitland-lib.sh | |
- name: Format in the opinionated DMFR format | |
run: | | |
find ./feeds -type f -name "*.dmfr.json" -exec transitland dmfr format --save {} \; | |
- name: "If any changes, run and store git diff" | |
id: git-diff | |
run: |- | |
if ! git_status_output="$(git status --porcelain)"; then | |
error_code="$?" | |
echo "'git status' had an error: $error_code" | |
exit 1 | |
elif [ -z "$git_status_output" ]; then | |
echo "Working directory is clean." | |
else | |
echo "Working directory has UNCOMMITTED CHANGES." | |
echo "GIT_DIFF<<EOF" >> "$GITHUB_OUTPUT" | |
git diff >> "$GITHUB_OUTPUT" | |
echo "EOF" >> "$GITHUB_OUTPUT" | |
fi | |
- uses: actions/github-script@v7 | |
if: ${{ steps.git-diff.outputs.GIT_DIFF != null }} | |
with: | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: 'transitland', | |
repo: 'transitland-atlas', | |
body: `***This PR includes a file that does not exactly follow the "opinionated" DMFR format*** | |
transitland-lib recommends the following changes: | |
\`\`\`diff | |
${{ steps.git-diff.outputs.GIT_DIFF }} | |
\`\`\` | |
You can use a code/text editor to make this change. Or use [transitland-lib](https://github.com/interline-io/transitland-lib/blob/main/dmfr-command.md). Or just wait and a maintainer will be glad to fix this. | |
Thanks for contributing to Transitland Atlas!` | |
}) |