commit 6eed0afd4d17888a9cbaad8417135c998a54177b Author: Maximilian Jugl Date: Tue Apr 21 15:35:01 2026 +0200 feat: initial diff --git a/.forgejo/workflows/test.yaml b/.forgejo/workflows/test.yaml new file mode 100644 index 0000000..b123f6b --- /dev/null +++ b/.forgejo/workflows/test.yaml @@ -0,0 +1,37 @@ +name: Test action + +on: + push: + branches: + - main + pull_request: + types: + - opened + - synchronize + - reopened + +jobs: + test-valid: + runs-on: stackit-docker + steps: + - uses: actions/checkout@v6 + - name: Test valid commit + uses: ./ + with: + value: "feat(core): add new validation" + + test-invalid: + runs-on: stackit-docker + steps: + - uses: actions/checkout@v6 + - name: Test invalid commit + id: test-fail + continue-on-error: true + uses: ./ + with: + value: "Added new validation" + - name: Check if test failed + if: steps.test-fail.outcome == 'success' + run: | + echo "The test should have failed but it succeeded." + exit 1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3596329 --- /dev/null +++ b/.gitignore @@ -0,0 +1,201 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.* +!.env.example + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist +.output + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp directory +.temp + +# Sveltekit cache directory +.svelte-kit/ + +# vitepress build output +**/.vitepress/dist + +# vitepress cache directory +**/.vitepress/cache + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# Firebase cache directory +.firebase/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# pnpm +.pnpm-store + +# yarn v3 +.pnp.* +.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/sdks +!.yarn/versions + +# Vite files +vite.config.js.timestamp-* +vite.config.ts.timestamp-* +.vite/ + +# General +.DS_Store +.localized +__MACOSX/ +.AppleDouble +.LSOverride +Icon[ ] + +# Resource forks +._* + +# Files and directories that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent +.com.apple.timemachine.supported +.PKInstallSandboxManager +.PKInstallSandboxManager-SystemSoftware +.hotfiles.btree +.vol +.file +.disk_label* +lost+found +.HFS+ Private Directory Data[ ] + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# Mac OS 6 to 9 +Desktop DB +Desktop DF +TheFindByContentFolder +TheVolumeSettingsFolder +.FBCIndex +.FBCSemaphoreFile +.FBCLockFolder + +# Quota system +.quota.group +.quota.user +.quota.ops.group +.quota.ops.user + +# TimeMachine +Backups.backupdb +.MobileBackups +.MobileBackups.trash +MobileBackups.trash +tmbootpicker.efi diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..963354f --- /dev/null +++ b/.prettierrc @@ -0,0 +1,3 @@ +{ + "printWidth": 120 +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..100de18 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "editor.formatOnSave": true, + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.tabSize": 2 +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..cc12bbe --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +# Check Conventional Commit Action + +This Forgejo Action validates whether a given string complies with the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/). + +## Usage + +Include this action in your workflow and pass the value to be tested (e.g., a pull request title or a commit message) via the `value` input. + +### Example Workflow + +```yaml +name: PR Validation +on: + pull_request: + types: + - opened + - synchronize + - reopened + +jobs: + check-pr-title: + runs-on: stackit-docker + steps: + - name: Validate PR Title + uses: https://stackit-solutions.git.onstackit.cloud/actions/check-conventional-commit@v1 + with: + value: ${{ github.event.pull_request.title }} +``` + +## Inputs + +- `value` (Required): The string (e.g., commit message) to be validated. diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..fb5bb41 --- /dev/null +++ b/action.yml @@ -0,0 +1,28 @@ +name: "Check conventional commit message" +description: "Checks if a value follows the conventional commit message specification." +inputs: + value: + description: "The value to test." + required: true + +runs: + using: "composite" + steps: + - name: Check conventional commit message + shell: bash + env: + INPUT_VALUE: ${{ inputs.value }} + run: | + set -eo pipefail + + CONVENTIONAL_COMMIT_REGEX='^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\([[:alnum:]._-]+\))?(!)?: .+' + + printf 'Checking "%s"...\n' "$INPUT_VALUE" + + if ! printf '%s\n' "$INPUT_VALUE" | grep -qE "$CONVENTIONAL_COMMIT_REGEX"; then + echo "::error title=Invalid Commit Message::Input '$INPUT_VALUE' is not a valid conventional commit message." + echo "Please refer to the specification: https://www.conventionalcommits.org/en/v1.0.0/" + exit 1 + else + echo "::notice::Input is valid :)" + fi diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..0b67f7e --- /dev/null +++ b/package-lock.json @@ -0,0 +1,28 @@ +{ + "name": "check-conventional-commit", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "devDependencies": { + "prettier": "^3.8.3" + } + }, + "node_modules/prettier": { + "version": "3.8.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.8.3.tgz", + "integrity": "sha512-7igPTM53cGHMW8xWuVTydi2KO233VFiTNyF5hLJqpilHfmn8C8gPf+PS7dUT64YcXFbiMGZxS9pCSxL/Dxm/Jw==", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..c689305 --- /dev/null +++ b/package.json @@ -0,0 +1,5 @@ +{ + "devDependencies": { + "prettier": "^3.8.3" + } +}