diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..6a7a4c1 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,46 @@ +--- +name: Build + +on: + pull_request: {} + + push: + branches: + - master + +jobs: + commitlint: + name: Commit Lint + runs-on: ubuntu-latest + + steps: + - name: Check out the codebase + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 21 + + - name: Install Node modules + run: npm install + + - name: Check program versions + run: | + node --version + npm --version + npm run commitlint -- --version + + - name: Validate last commit + if: github.event_name == 'push' + run: npm run commitlint -- --from=HEAD~1 --to=HEAD --verbose + + - name: Validate commits in pull request + if: github.event_name == 'pull_request' + run: >- + npm run commitlint -- + --from=${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} + --to=${{ github.event.pull_request.head.sha }} + --verbose diff --git a/.husky/commit-msg b/.husky/commit-msg index 482222a..45c2c4d 100755 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -1,4 +1,4 @@ #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" -npm run commitlint ${1} +npm run lint-commit-msg ${1} diff --git a/package.json b/package.json index 0e5eef2..f4d541b 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ }, "scripts": { "prepare": "husky install", - "commitlint": "commitlint --edit" + "lint-commit-msg": "commitlint --edit", + "commitlint": "commitlint" } } \ No newline at end of file