Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
DirtDiglett committed Mar 25, 2020
1 parent 458a7ae commit f08e03b
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 2 deletions.
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM php:7.4-cli

RUN apt-get update && apt-get -y install zip unzip

RUN curl -sS https://getcomposer.org/installer | php -- \
--install-dir=/usr/bin --filename=composer && chmod +x /usr/bin/composer

RUN mkdir /twigcs && cd /twigcs && composer require friendsoftwig/twigcs && ln -s /twigcs/vendor/bin/twigcs /usr/local/bin/twigcs

COPY "entrypoint.sh" "/entrypoint.sh"
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
37 changes: 35 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,35 @@
# actions-twigcs
TwigCS Action for GitHub Actions
# GitHub Action for TwigCS
GitHub Action implementation of the TwigCS Package provided by [https://github.com/friendsoftwig/twigcs](@friendsoftwig/twigcs).

## Inputs

### `dir`

The folder to run twigcs recursively from.

Default `'.'`.

### `severity_tolerance`

The exit code of TwigCS is based on the severity of any violation found. By default, twigcs only tolerates notices, this input changes this.

Available options:
`error` - Allows notices and warnings
`notice` - Disallows notices
`ignore` - Allows everything

Default `notice`.

### `ignore_folder`

Optional: Name of a subfolder to exclude.

## Example usage

```
uses: DirtDiglett/actions-twigcs@v1
with:
dir: ./src/views
severity_tolerance: notice
ignore_folder: vendor
```
27 changes: 27 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: 'Twigcs'
description: 'A GitHub Action that runs Twigcs on a repository.'
author: 'DirtDiglett'

branding:
icon: 'eye'
color: 'orange'

inputs:
dir:
description: 'Folder to check code style'
required: false
default: .
severity_tolerance:
description: 'What level of exit code should be tolerated'
required: false
ignore_folder:
description: 'Ignore subfolders that match name'
required: false

runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.dir }}
- ${{ inputs.severity_tolerance }}
- ${{ inputs.ignore_folder }}
19 changes: 19 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash -l
set -e

PHP_FULL_VERSION=$(php -r 'echo phpversion();')

echo "======================"
echo "= Running TwigCS ="
echo "======================"
echo "PHP Version : ${PHP_FULL_VERSION}"

if [[ -n "$INPUT_SEVERITY_TOLERANCE" ]]; then
options+=(-c "$INPUT_SEVERITY_TOLERANCE")
fi

if [[ -n "$INPUT_IGNORE_FOLDER" ]]; then
options+=(-c "$INPUT_IGNORE_FOLDER")
fi

twigcs $INPUT_DIR "${options[@]}"

0 comments on commit f08e03b

Please sign in to comment.