Skip to content

Commit

Permalink
ci: adding GitHub Actions workflow formatting check
Browse files Browse the repository at this point in the history
  • Loading branch information
DeveloperC286 committed Sep 10, 2024
1 parent 227841d commit 24800d0
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/github-actions-workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 18 additions & 0 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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/[email protected]
Expand Down
6 changes: 6 additions & 0 deletions ci/check-yaml-formatting.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

set -o errexit
set -o xtrace

yamlfmt -lint -dstar .github/**/*
6 changes: 6 additions & 0 deletions ci/fix-yaml-formatting.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env sh

set -o errexit
set -o xtrace

yamlfmt -dstar ./github/**/*

0 comments on commit 24800d0

Please sign in to comment.