A GitHub Action to run Air.
Input | Description | Default |
---|---|---|
args |
The arguments to pass to the air command. See configuring Air. If none are provided, air is installed and added to the PATH but not invoked. |
None |
version |
The version of Air to install. See Install specific versions. | latest |
github-token |
The GitHub token to use for authentication. Generally not required. | secrets.GITHUB_TOKEN |
Output | Description |
---|---|
air-version |
The version of Air that was installed. |
If you'd like to use Air to enforce style on your repository, the easiest way to get started is to use usethis to copy the example action from examples/format-check.yaml
into your .github/workflows
folder.
usethis::use_github_action(url = "https://github.com/posit-dev/air-action/blob/main/examples/format-check.yaml")
This runs air format . --check
on every push to main
and on every pull request.
If any files would be reformatted, the action fails.
When this happens, reformat locally using air format .
or the Air: Format Workspace Folder
command in VS Code or Positron, and commit and push the results.
In the following subsections, we explore a variety of ways to customize posit-dev/air-action
.
The most common way to use this action is to perform a format --check
on each pull request to ensure that the code within the pull request is correctly formatted.
- uses: posit-dev/air-action@v1
with:
args: format . --check
If you'd like to actually format the files, just use format
.
- uses: posit-dev/air-action@v1
with:
args: format .
On a specific directory:
- uses: posit-dev/air-action@v1
with:
args: format ./directory
Note that if you combine this with another action to commit and push these reformatted files back to a branch or pull request, the push will not retrigger any of your GitHub Workflows. This means you won't get any feedback that the push has fixed any broken formatting. Instead, we recommend that you reformat locally and push the changed files back up using a standard commit that will retrigger all of your checks.
This action adds Air to the PATH
, so you can use it in subsequent steps.
- name: Install Air
uses: posit-dev/air-action@v1
- name: Actually run Air
run: air format .
By default, no Air commands are performed in the posit-dev/air-action
installation step unless args
are provided.
By default this action installs the latest version of Air. You can also request a specific version, or a semver compatible range.
- name: Install the latest version of Air
uses: posit-dev/air-action@v1
with:
version: "latest"
- name: Install a specific version of Air
uses: posit-dev/air-action@v1
with:
version: "0.4.4"
You can specify a semver range to install the latest version that satisfies the range.
- name: Install a semver range of Air
uses: posit-dev/air-action@v1
with:
version: ">=0.4.0"
- name: Pinning a minor version of Air
uses: posit-dev/air-action@v1
with:
version: "0.4.x"
This action uses the GitHub API to fetch the Air release artifacts.
By default, the GITHUB_TOKEN
secret is used, which is automatically provided by GitHub Actions.
If the default permissions for the GitHub token are not sufficient, you can provide a custom GitHub token with the necessary permissions.
- name: Install the latest version of Air with a custom GitHub token
uses: posit-dev/air-action@v1
with:
github-token: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
This is a fork of the great ruff-action.