Skip to content

Commit

Permalink
GitHub Actions workflow to automatically try applying opionated DMFR …
Browse files Browse the repository at this point in the history
…format to new PRs
  • Loading branch information
drewda committed Jun 18, 2024
1 parent a7647a0 commit 96b3e1d
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/format.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Apply opinionated DMFR format to PRs
on: [pull_request, push]
jobs:
format:
if: github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- 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: commit and push"
run: |-
git config user.name "Automated Bot"
git config user.email "[email protected]"
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."
git add -A
git commit -m "Apply opinionated DMFR format"
git push
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 96b3e1d

Please sign in to comment.