Rename to validate

This commit is contained in:
Sébastiaan 2025-01-05 13:16:11 +01:00
parent 63ac679065
commit bcbc79827e

View File

@ -1,4 +1,4 @@
name: Check file formatting name: Validate script formatting
on: on:
push: push:
@ -8,10 +8,11 @@ on:
paths: paths:
- "**/*.sh" - "**/*.sh"
- "**/*.func" - "**/*.func"
- ".github/workflows/validate-formatting.yaml"
jobs: jobs:
shfmt: shfmt:
name: Shell scripts name: Check changed files
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
pull-requests: write pull-requests: write
@ -22,14 +23,6 @@ jobs:
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
- name: Install shfmt
run: |
go install mvdan.cc/sh/v3/cmd/shfmt@latest
echo "$GOPATH/bin" >> $GITHUB_PATH
- name: Get changed files - name: Get changed files
id: changed-files id: changed-files
run: | run: |
@ -39,7 +32,18 @@ jobs:
echo "files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep -E '\.(sh|func)$' | xargs)" >> $GITHUB_OUTPUT echo "files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep -E '\.(sh|func)$' | xargs)" >> $GITHUB_OUTPUT
fi fi
- name: Set up Go
if: steps.changed-files.outputs.files != ''
uses: actions/setup-go@v5
- name: Install shfmt
if: steps.changed-files.outputs.files != ''
run: |
go install mvdan.cc/sh/v3/cmd/shfmt@latest
echo "$GOPATH/bin" >> $GITHUB_PATH
- name: Run shfmt - name: Run shfmt
if: steps.changed-files.outputs.files != ''
id: shfmt id: shfmt
run: | run: |
set +e set +e
@ -54,7 +58,7 @@ jobs:
fi fi
- name: Post comment with results - name: Post comment with results
if: always() && github.event_name == 'pull_request' if: always() && steps.changed-files.outputs.files != '' && github.event_name == 'pull_request'
uses: actions/github-script@v7 uses: actions/github-script@v7
with: with:
script: | script: |
@ -66,7 +70,7 @@ jobs:
const issueNumber = context.payload.pull_request const issueNumber = context.payload.pull_request
? context.payload.pull_request.number ? context.payload.pull_request.number
: null; : null;
const commentIdentifier = "formatting-check"; const commentIdentifier = "validate-formatting";
let newCommentBody = `<!-- ${commentIdentifier}-start -->\n### Script formatting\n\n`; let newCommentBody = `<!-- ${commentIdentifier}-start -->\n### Script formatting\n\n`;
if (result === "failure") { if (result === "failure") {