diff --git a/.github/workflows/format-pr.yml b/.github/workflows/format-pr.yml new file mode 100644 index 0000000..9681588 --- /dev/null +++ b/.github/workflows/format-pr.yml @@ -0,0 +1,46 @@ +name: "Format PR" + +on: + workflow_call: + inputs: + directory: + description: "The directory on which JuliaFormatter needs to be run" + default: "." + required: false + type: string + julia-version: + description: "Julia version" + default: "1" + required: false + type: string + juliaformatter-version: + description: "Version of JuliaFormatter to use" + default: "1.10" + required: false + type: string + +jobs: + check-formatting: + name: "Check Formatting" + uses: "./.github/workflows/format-check.yml" + with: + directory: "${{ inputs.directory }}" + julia-version: "${{ inputs.julia-version }}" + juliaformatter-version: "${{ inputs.juliaformatter-version }}" + fail-if-unformatted: false + + open-pr: + needs: check-formatting + if: ${{ !needs.check-formatting.outputs.formatted }} + runs-on: ubuntu + steps: + - uses: "actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608" # v4.1.0 + + - run: echo "${{ needs.check-formatting.outputs.format-diff-patch }}" | git apply --quiet + + - uses: reviewdog/action-suggester@v1 + with: + github_token: ${{ secrets.DOCUMENTER_KEY }} + tool_name: JuliaFormatter + fail_on_error: true + filter_mode: added