name: fourmolu on: push jobs: format: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: token: ${{ secrets.GITHUB_TOKEN }} - name: Cache fourmolu id: cache-fourmolu uses: actions/cache@v3 with: path: ~/.local/bin/fourmolu key: fourmolu-0.19.0.0 - name: Install fourmolu if: steps.cache-fourmolu.outputs.cache-hit != 'true' run: | mkdir -p ~/.local/bin curl -sL https://github.com/fourmolu/fourmolu/releases/download/v0.19.0.0/fourmolu-0.19.0.0-linux-x86_64 -o ~/.local/bin/fourmolu chmod +x ~/.local/bin/fourmolu - name: Add fourmolu to PATH run: echo "$HOME/.local/bin" >> $GITHUB_PATH - name: Format code run: make fmt - name: Commit formatted code run: | git config --local user.email "github-actions[bot]@users.noreply.github.com" git config --local user.name "github-actions[bot]" git add -A git diff --staged --quiet || git commit -m "Auto-format code with fourmolu" - name: Push changes uses: ad-m/github-push-action@master with: github_token: ${{ secrets.GITHUB_TOKEN }} branch: ${{ github.ref }}