diff --git a/README.ja.md b/README.ja.md index 3ac6985..8bf0c91 100644 --- a/README.ja.md +++ b/README.ja.md @@ -8,6 +8,33 @@ YAML ファイルを自動的に整形するための GitHub Actions 用アクションです。コードの一貫性を保ち、レビューやデバッグを容易にします。 +## TL;DR + +```yaml +name: YAML Formatting + +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] + workflow_dispatch: + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: yamllint + uses: reviewdog/action-yamllint@v1 + with: + github_token: ${{ secrets.github_token }} + fail_on_error: true + - name: yamlfmt + uses: yk-lab/yamlfmt-action@v1 +``` + ## 特徴 - **自動フォーマット**: `yamlfmt` を使用して YAML ファイルを統一的に整形。 @@ -50,6 +77,7 @@ jobs: アクションには以下の入力パラメータがあります。 +- `version`: `yamlfmt` のバージョン (デフォルト: `latest`, 例: `v0.13.0`) - `path`: フォーマットする YAML ファイルまたはディレクトリのパス - `dstar`: ダブルスター展開を有効にする - `exclude`: 指定したパターンに一致するファイルを除外 diff --git a/README.md b/README.md index 889ed63..6924992 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,33 @@ English | [日本語](README.ja.md) Automatically format YAML files using `yamlfmt` in your GitHub Actions workflows. This action helps maintain consistent code style, making reviews and debugging easier. +## TL;DR + +```yaml +name: YAML Formatting + +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] + workflow_dispatch: + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: yamllint + uses: reviewdog/action-yamllint@v1 + with: + github_token: ${{ secrets.github_token }} + fail_on_error: true + - name: yamlfmt + uses: yk-lab/yamlfmt-action@v1 +``` + ## Features - **Automatic Formatting**: Uses `yamlfmt` to standardize the formatting of YAML files. @@ -50,6 +77,7 @@ jobs: The action supports the following input parameters: +- `version`: Version of `yamlfmt` to use (default: `latest`, e.g., `v0.13.0`) - `path`: Path to the YAML file or directory to format - `dstar`: Enable double-star expansion - `exclude`: Exclude files matching the specified pattern diff --git a/action.yml b/action.yml index 3877972..1f8c000 100644 --- a/action.yml +++ b/action.yml @@ -6,6 +6,10 @@ branding: color: gray-dark inputs: + version: + description: 'The version of yamlfmt to use' + required: false + default: 'latest' path: description: 'Path to the YAML file or directory to format' required: false @@ -56,8 +60,14 @@ runs: shell: bash - id: get_yamlfmt_version - name: Get yamlfmt latest version - run: echo "version=$(go list -m -versions -json github.com/google/yamlfmt | jq -r '.Versions[-1]')" >> $GITHUB_OUTPUT + name: Get yamlfmt version + run: | + if [ "${{ inputs.version }}" = "latest" ]; then + version=$(go list -m -versions -json github.com/google/yamlfmt | jq -r '.Versions[-1]') + else + version="${{ inputs.version }}" + fi + echo "version=$version" >> $GITHUB_OUTPUT shell: bash - id: cache_gobin @@ -69,7 +79,7 @@ runs: - name: Install yamlfmt if: steps.cache_gobin.outputs.cache-hit != 'true' - run: go install github.com/google/yamlfmt/cmd/yamlfmt@latest + run: go install github.com/google/yamlfmt/cmd/yamlfmt@${{ steps.get_yamlfmt_version.outputs.version }} shell: bash - id: build_command