IntelliJ Code Format
ActionsTags
(1)A GitHub Action that formats your code using the IntelliJ formatter.
Both examples implement caching of downloaded IDEA files (~900MB).
Cache generation might take a while on the first run, but saves bandwidth and is faster later on.
NOTE: If the actions fails due to the formatting changing files, cache will not be saved.
Formats all files that are supported by the formatter in your repository and creates a pull request with the changes whenever there's a push to the main branch:
name: IntelliJ Format
on:
push:
branches: ["main"]
jobs:
formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache IDEA
uses: actions/cache@v3
with:
path: /home/runner/work/_temp/_github_workflow/idea-cache
key: ${{ runner.os }}-idea-cache
- uses: notdevcody/intellij-format-action@v3.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}Formats all files that are supported by the formatter in your repository and creates a pull request whenever there's a push to the main branch, including PRs to it:
name: IntelliJ Format
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
jobs:
formatting:
runs-on: ubuntu-latest
steps:
- if: github.event_name != 'pull_request'
uses: actions/checkout@v4
- if: github.event_name == 'pull_request'
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Cache IDEA
uses: actions/cache@v3
with:
path: /home/runner/work/_temp/_github_workflow/idea-cache
key: ${{ runner.os }}-idea-cache
- uses: notdevcody/intellij-format-action@v3.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}Formats all files that are supported by the formatter in your repository and directly commits the changes whenever there's a push to the main branch:
name: IntelliJ Format
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
jobs:
formatting:
runs-on: ubuntu-latest
steps:
- if: github.event_name != 'pull_request'
uses: actions/checkout@v4
- if: github.event_name == 'pull_request'
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Cache IDEA
uses: actions/cache@v3
with:
path: /home/runner/work/_temp/_github_workflow/idea-cache
key: ${{ runner.os }}-idea-cache
- uses: notdevcody/intellij-format-action@v3.1
push-type: "commit"While none of these inputs are mandatory, you can specify them to modify the action's behavior.
Pattern for files to include. Supports glob-style wildcards. Multiple patterns can be separated by commas.
Default: *.*
Path to project directory. The formatter is executed recursively from here.
Must be relative to the workspace.
Default: .
Type of push to perform.
Options are commit, pull-request or none.
Default: pull-request
The title to use for the commit or pull request.
Default: IntelliJ Code Format
The description to use for the pull request.
Unused for commits.
Default: Empty
Fail if any files were changed by the formatter.
Default: true
A path to IntelliJ IDEA code style settings .xml file.
Leave default if you want the formatter to use .editorconfig files.
Default: unset (-allowDefaults argument)
Mute the formatter output. Action output will still be logged.
Default: true
Outputs the number of files which were formatted.
Zero if none changed.
IntelliJ Code Format is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.