From a25386bb892f46321a542c9f01983b205a891054 Mon Sep 17 00:00:00 2001 From: mrdcvlsc Date: Fri, 30 Jun 2023 22:43:38 +0800 Subject: [PATCH] auto code format on push --- .github/workflows/format.yml | 39 ++++++++++++++++++++++ app.js | 24 ++++++++++--- .github/workflows/linter.yml => linter.yml | 4 +-- .github/workflows/tests.yml => tests.yml | 0 4 files changed, 61 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/format.yml rename .github/workflows/linter.yml => linter.yml (95%) rename .github/workflows/tests.yml => tests.yml (100%) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000..b33904e --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,39 @@ +name: format + +on: + push: + branches: [ "master", "main" ] + +jobs: + format-code-on-push: + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - name: Checkout Repo + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Configure Email + run: git config --local user.email ${{ github.event.pusher.email }} + + - name: Configure Name + run: git config --local user.name ${{ github.event.pusher.name }} + + - name: Git Status + run: git status + + - name: Format Code Style + run: npm run format + + - name: Stage Changes + run: git add . + + - name: Save Changes + run: git commit -m "Format:${{ github.event.head_commit.message }}" + + - name: Push Changes + run: git push --force \ No newline at end of file diff --git a/app.js b/app.js index 7cf7290..4a97fcb 100644 --- a/app.js +++ b/app.js @@ -1,12 +1,28 @@ import path from 'path'; -import { fileURLToPath } from 'url'; +import { + + + + + + fileURLToPath } from 'url'; import { showLocalNetworkIP } from './shownet.js'; -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); +const __filename = +fileURLToPath( + import.meta.url + + + + ); + + +const __dirname = path. +dirname(__filename); const PORT = process.env.PORT || 8080; -showLocalNetworkIP(PORT); +showLocalNetworkIP( + PORT); import fastify from 'fastify'; diff --git a/.github/workflows/linter.yml b/linter.yml similarity index 95% rename from .github/workflows/linter.yml rename to linter.yml index 8ea6556..66ee6bf 100644 --- a/.github/workflows/linter.yml +++ b/linter.yml @@ -37,8 +37,8 @@ jobs: # VALIDATE_PYTHON_BLACK: true VALIDATE_JAVASCRIPT_ES: true - VALIDATE_HTML: true - VALIDATE_CSS: true + # VALIDATE_HTML: true + # VALIDATE_CSS: true # where your linter config files should go like; # .prettierrc.json, .clang-fromat, .eslintrc.yml, .htmlhintrc, etc. diff --git a/.github/workflows/tests.yml b/tests.yml similarity index 100% rename from .github/workflows/tests.yml rename to tests.yml