Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(action): Add semantic-release and pre-commit to repo #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/commitlint.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
15 changes: 15 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
15 changes: 8 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -11,17 +11,18 @@ 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]
- id: detect-aws-credentials
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
5 changes: 5 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
extends: [
"@commitlint/config-conventional"
]
}
26 changes: 2 additions & 24 deletions githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
]
}