diff --git a/.github/workflows/commitlint.yaml b/.github/workflows/commitlint.yaml new file mode 100644 index 0000000..74f7cc0 --- /dev/null +++ b/.github/workflows/commitlint.yaml @@ -0,0 +1,16 @@ +name: Publish +on: [pull_request, push] +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup Node.js + uses: actions/setup-node@v1 + with: + node-version: 16 + - name: Semantic Release + uses: cycjimmy/semantic-release-action@v3 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml new file mode 100644 index 0000000..58eee82 --- /dev/null +++ b/.github/workflows/pre-commit.yaml @@ -0,0 +1,15 @@ +on: + pull_request: + push: + branches: [main, test-me-*] + +jobs: + main: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v3 + - name: Run Pre-commit Hook and Post to PR comment + uses: dasmeta/reusable-actions-workflows/pre-commit@0.0.7 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5ae84b7..4b036a3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.2.0 + rev: v4.3.0 hooks: - id: check-added-large-files - id: check-merge-conflict @@ -11,7 +11,6 @@ repos: exclude: CHANGELOG.md - id: check-yaml - id: check-merge-conflict - - id: check-executables-have-shebangs - id: check-case-conflict - id: mixed-line-ending args: [--fix=lf] @@ -19,9 +18,11 @@ repos: args: ['--allow-missing-credentials'] - id: detect-private-key - repo: https://github.com/antonbabenko/pre-commit-terraform - rev: v1.62.3 + rev: v1.64.1 hooks: - - id: terraform_fmt - - id: terraform_docs - args: - - '--args=--lockfile=false' + - id: terraform_fmt + - id: terraform_docs + args: + - --hook-config=--path-to-file=README.md + - --hook-config=--add-to-existing-file=true + - --hook-config=--create-file-if-not-exist=true diff --git a/commitlint.config.js b/commitlint.config.js new file mode 100644 index 0000000..81c4b92 --- /dev/null +++ b/commitlint.config.js @@ -0,0 +1,5 @@ +module.exports = { + extends: [ + "@commitlint/config-conventional" + ] +} diff --git a/githooks/pre-commit b/githooks/pre-commit index db3c56e..c3aacd8 100755 --- a/githooks/pre-commit +++ b/githooks/pre-commit @@ -1,26 +1,4 @@ #!/bin/bash -echo "Start git pre-commit hooks"; - -echo "Start terraform docs"; -for i in `ls -d modules/*/`;do - if ! git diff --cached --quiet "${i}" - then - echo "Generating doc file: ${i}"; - terraform-docs markdown table --output-file README.md --output-mode inject "${i}"; - fi -done -echo "End terraform docs"; - -echo "Start terraform fmt"; -for y in $(find . -name '*.tf' -print) - do - if ! git diff --cached --quiet "${y}" - then - echo "Formatting the file: ${y}"; - terraform fmt -write=true "${y}" - fi -done -echo "End terraform fmt"; - -echo "End git pre-commit hooks"; +set -e +pre-commit run --show-diff-on-failure --color=always --all-files diff --git a/package.json b/package.json new file mode 100644 index 0000000..1782661 --- /dev/null +++ b/package.json @@ -0,0 +1,22 @@ +{ + "name": "app", + "devDependencies": { + "@commitlint/cli": "^17.0.3", + "@commitlint/config-conventional": "^17.0.3", + "husky": "^8.0.1", + "@semantic-release/github": "^8.0.4", + "semantic-release": "^19.0.3" + }, + "release": { + "branches": [ + "main", "master", "next" + ] + }, + "private": true, + "plugins": [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + "@semantic-release/github", + "@semantic-release/npm" + ] +}