commit 766e12d0c330739984ee1629642438197a1a4afe Author: Luke Tainton Date: Thu Jan 2 22:29:07 2025 +0000 Initial diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e49260d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +# Container image that runs your code +FROM alpine:3.21 + +# Install python/pip +ENV PYTHONUNBUFFERED=1 +RUN apk add --update --no-cache python3 && \ + ln -sf python3 /usr/bin/python && \ + python3 -m ensurepip && \ + pip3 install --no-cache --upgrade pip setuptools conventional-pre-commit + +# Copies your code file from your action repository to the filesystem path `/` of the container +COPY entrypoint.sh /entrypoint.sh + +# Code file to execute when the docker container starts up (`entrypoint.sh`) +ENTRYPOINT ["/entrypoint.sh"] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..cde4ac6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,10 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. + +In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to diff --git a/README.md b/README.md new file mode 100644 index 0000000..5d54c46 --- /dev/null +++ b/README.md @@ -0,0 +1,50 @@ +# Conventional Commits Check Action + +A [GitHub Action](https://github.com/features/actions) / [Gitea Action](https://docs.gitea.com/usage/actions/overview) for enforcing adherance to [Conventional Commits](https://pypi.org/project/conventional-pre-commit/). + +You can use the Action as follows: + +```yaml +name: Validate PR Title +on: + pull_request_target: + types: + - opened + - edited + - synchronize + - reopened + - labeled + - unlabeled +jobs: + validate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - uses: https://git.tainton.uk/actions/conventional-commits-docker-actiom@v1 + with: + commit-message: ${{ github.event.pull_request.title }} +``` + +```yaml +name: Validate Commit Message +on: + push: + branches: + - main +jobs: + validate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - uses: https://git.tainton.uk/actions/conventional-commits-docker-actiom@v1 + with: + commit-message: ${{ github.event.head_commit.message }} +``` + +## Properties + +The Conventional Commits Check Action has a property which is passed to the underlying script. These are passed to the action using `with`. + +| Property | Description | +| -------------- | ---------------------------------------------- | +| commit-message | The commit message you would like to validate. | diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..31cbc60 --- /dev/null +++ b/action.yml @@ -0,0 +1,11 @@ +name: 'Conventional Commits Check' +description: 'A GitHub/Gitea Action for enforcing adherance to Conventional Commits.' +inputs: + commit-message: # id of input + description: 'Commit message, PR title, etc. to check' + required: true +runs: + using: 'docker' + image: 'Dockerfile' + args: + - ${{ inputs.commit-message }} diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..6a23d09 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/sh -l + +set -e + +PRTITLE="$1" +echo "PRTITLE" > /tmp/prtitle.txt +conventional-pre-commit --no-color --force-scope --strict --verbose /tmp/prtitle.txt