forked from transitland/transitland-atlas
-
-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (54 loc) · 2.07 KB
/
format.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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!`
})