diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..369db9f --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,37 @@ +name: Continous integration + +on: [push, pull_request] + +jobs: + build_and_lint: + timeout-minutes: 30 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Install commitlint + run: | + npm i -g @commitlint/config-conventional @commitlint/cli + + - name: Install dependancies and build + run: | + if [ -f package.json ]; then + npm ci + npm run build + else + echo "package.json not found, skipping build step" + fi + shell: bash + + - name: Validate commit messages + if: github.event_name == 'push' + run: | + commitlint -x @commitlint/config-conventional --from HEAD~1 --to HEAD --verbose + + - name: Validate PR commits with commitlint + if: github.event_name == 'pull_request' + run: commitlint -x @commitlint/config-conventional --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose