From 94b4f43fc38663bc80af4b2bdde1a63b1bdbcb05 Mon Sep 17 00:00:00 2001 From: Agli Panci Date: Fri, 24 Jun 2022 16:08:52 +0200 Subject: [PATCH] WIP --- .dockerignore | 5 +++++ Dockerfile | 8 ++++++++ README.md | 22 ++++++++++++++++++++++ action.yml | 30 ++++++++++++++++++++++++++++++ entrypoint.sh | 24 ++++++++++++++++++++++++ 5 files changed, 89 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 action.yml create mode 100755 entrypoint.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..8b73f62 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +# ignore all files by default +* +# include required files with an exception +!entrypoint.sh +!README.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..72f7829 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM composer:latest + +RUN composer global require laravel/pint --no-progress --dev +ENV PATH="/tmp/vendor/bin:${PATH}" + +COPY "entrypoint.sh" "/entrypoint.sh" +RUN chmod +x /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..645c316 --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# GitHub Action for Laravel Pint + +GitHub Action implementation of the [Laravel Pint](https://github.com/laravel/pint) Package. + +## Usage + +Use with [GitHub Actions](https://github.com/features/actions) + +_.github/workflows/pint.yml_ + +``` +name: PHP Linting +on: pull_request +jobs: + phplint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: aglipanci/laravel-pint-action@main +``` + +If provided, a `pint.json` file in the root will be used for configuration during run of the Action. \ No newline at end of file diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..c5d7596 --- /dev/null +++ b/action.yml @@ -0,0 +1,30 @@ +name: 'Laravel Pint' +description: 'Laravel Pint is an opinionated PHP code style fixer for minimalists.' +author: 'Agli Panci ' +inputs: + testMode: + description: "would you like to run Pint on test mode" + required: false + + verboseMode: + description: "would you like to run Pint on verbose mode" + required: false + + configPath: + description: "specify the custom config path" + required: false + + preset: + description: "pint preset" + required: false +runs: + using: 'docker' + image: 'Dockerfile' + args: + - ${{ inputs.test-mode }} + - ${{ inputs.verbose-mode }} + - ${{ inputs.config-path }} + - ${{ inputs.preset }} +branding: + icon: 'eye' + color: 'gray-dark' \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..118947c --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -e + +command_string=("pint") + +if [[ "${INPUT_TESTMODE}" ]]; then + command_string+=" --test" +fi + +if [[ "${INPUT_VERBOSEMODE}" ]]; then + command_string+=" -v" +fi + +if [[ "${INPUT_CONFIGPATH}" ]]; then + command_string+=" --config ${INPUT_CONFIGPATH}" +fi + +if [[ "${INPUT_PRESET}" ]]; then + command_string+=" --preset ${INPUT_PRESET}" +fi + +echo "Running Command: " "${command_string[@]}" + +${command_string[@]} \ No newline at end of file