diff --git a/.gitea/workflows/check-license.yml b/.gitea/workflows/check-license.yml new file mode 100644 index 0000000..113054b --- /dev/null +++ b/.gitea/workflows/check-license.yml @@ -0,0 +1,29 @@ +# Copyright Avroid, Ltd. 2023-2024 +# +# You can not use the contents of the file in any way without +# AVROID, Ltd. written permission. +# +# To obtain such a permit, you should contact AVROID, Ltd. +# at https://avroid.ru + +--- +name: Check license +run-name: ${{ gitea.actor }} is start check sources +on: [pull_request] + +jobs: + scan-secrets: + name: Check license + runs-on: docker + container: + image: harbor.avroid.tech/devops/node:20-alpine3.19-0 + steps: + - run: echo "Start job on ${{ runner.name }} with os ${{ runner.os }}" + - run: echo "Work with branch ${{ gitea.ref }} repository ${{ gitea.repository }}" + - name: Check out repository code + uses: https://gitea:${{ secrets.CI_TOKEN }}@git.avroid.tech/Mirrors/github-actions-checkout.git@v4 + with: + fetch-depth: 0 # for work tj-actions/changed-files + persist-credentials: false # for work tj-actions/changed-files + - name: Check license + uses: https://gitea:${{ secrets.CI_TOKEN }}@git.avroid.tech/Actions/addlicense-docker-action.git@v1 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8854f46 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +# Copyright Avroid, Ltd. 2023-2024 +# +# You can not use the contents of the file in any way without +# AVROID, Ltd. written permission. +# +# To obtain such a permit, you should contact AVROID, Ltd. +# at https://avroid.ru + +FROM harbor.avroid.tech/devops/addlicense:1.1.1 + +COPY entrypoint.sh /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md index 7c84065..74fe289 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,39 @@ # addlicense-docker-action +Action для проверки лицензии в файлах + +[Ссылка на проект](https://git.avroid.tech/Tools/Addlicense) + +Пример использования + +```yaml +--- +name: Check license +run-name: ${{ gitea.actor }} is start check sources +on: [pull_request] + +jobs: + scan-secrets: + name: Check license + runs-on: docker + container: + image: harbor.avroid.tech/devops/node:20-alpine3.19-0 + steps: + - run: echo "Start job on ${{ runner.name }} with os ${{ runner.os }}" + - run: echo "Work with branch ${{ gitea.ref }} repository ${{ gitea.repository }}" + - name: Check out repository code + uses: https://gitea:${{ secrets.CI_TOKEN }}@git.avroid.tech/Mirrors/github-actions-checkout.git@v4 + with: + fetch-depth: 0 # for work tj-actions/changed-files + persist-credentials: false # for work tj-actions/changed-files + - name: Check license + uses: https://gitea:${{ secrets.CI_TOKEN }}@git.avroid.tech/Actions/addlicense-docker-action.git@v1 + with: + exclude_pattern: -ignore "**/*.go" -ignore "vendor/**" +``` + +## Параметры использования + +Данный параметр позволяет исключить файлы или директории из проверки на наличие лицензии. + +**exclude_pattern:** ```-ignore "**/*.go" -ignore "vendor/**"``` diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..69fe4bc --- /dev/null +++ b/action.yml @@ -0,0 +1,20 @@ +# Copyright Avroid, Ltd. 2023-2024 +# +# You can not use the contents of the file in any way without +# AVROID, Ltd. written permission. +# +# To obtain such a permit, you should contact AVROID, Ltd. +# at https://avroid.ru + +name: 'Addlicense action' +description: 'Checks license and notify about missing license headers' +inputs: + exclude_pattern: + description: 'Pattern for exclude files' + required: false +outputs: +runs: + using: 'docker' + image: 'Dockerfile' + args: + - ${{ inputs.exclude_pattern }} diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..5787d7e --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,14 @@ +#!/bin/sh +# Copyright Avroid, Ltd. 2023-2024 +# +# You can not use the contents of the file in any way without +# AVROID, Ltd. written permission. +# +# To obtain such a permit, you should contact AVROID, Ltd. +# at https://avroid.ru + + +echo "Processing event '$GITHUB_EVENT_NAME'" +echo "List of files no has license:" +echo "===================================" +echo /app/addlicense -check "$1" . | sh