diff --git a/.github/workflows/github-actions-workflows.yml b/.github/workflows/github-actions-workflows.yml index a8816bf..aebb806 100644 --- a/.github/workflows/github-actions-workflows.yml +++ b/.github/workflows/github-actions-workflows.yml @@ -17,3 +17,13 @@ jobs: uses: actions/checkout@v3 - name: Check GitHub Actions workflows linting. run: earthly +check-github-actions-workflows-linting + formatting: + name: Formatting + runs-on: ubuntu-latest + steps: + - name: Download Earthly v0.8.6. + run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.8.6/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'" + - name: Checkout code. + uses: actions/checkout@v3 + - name: Check formatting. + run: earthly +check-yaml-formatting diff --git a/Earthfile b/Earthfile index be2d561..8a83415 100644 --- a/Earthfile +++ b/Earthfile @@ -33,6 +33,24 @@ check-conventional-commits-linting: RUN ./ci/check-conventional-commits-linting.sh --from-reference "${from_reference}" +yaml-formatting-base: + FROM +golang-base + RUN go install github.com/google/yamlfmt/cmd/yamlfmt@v0.10.0 + COPY ".yamlfmt" "./" + DO +COPY_CI_DATA + + +check-yaml-formatting: + FROM +yaml-formatting-base + RUN ./ci/check-yaml-formatting.sh + + +fix-yaml-formatting: + FROM +yaml-formatting-base + RUN ./ci/fix-yaml-formatting.sh + SAVE ARTIFACT ".github/" AS LOCAL "./" + + check-github-actions-workflows-linting: FROM golang:1.20.13 RUN go install github.com/rhysd/actionlint/cmd/actionlint@v1.6.26 diff --git a/ci/check-yaml-formatting.sh b/ci/check-yaml-formatting.sh new file mode 100755 index 0000000..d39cb5a --- /dev/null +++ b/ci/check-yaml-formatting.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -o errexit +set -o xtrace + +yamlfmt -lint -dstar .github/**/* diff --git a/ci/fix-yaml-formatting.sh b/ci/fix-yaml-formatting.sh new file mode 100755 index 0000000..7f5c712 --- /dev/null +++ b/ci/fix-yaml-formatting.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env sh + +set -o errexit +set -o xtrace + +yamlfmt -dstar ./github/**/*