diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..e335a3b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,18 @@ +# .github/workflows/release.yml +name: Release + +on: + pull_request: + types: closed + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Tag + uses: K-Phoen/semver-release-action@master + with: + release_branch: main + tag_format: "%major%.%minor%.%patch%" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/update-reviewdog.yml b/.github/workflows/update-reviewdog.yml new file mode 100644 index 0000000..041cd99 --- /dev/null +++ b/.github/workflows/update-reviewdog.yml @@ -0,0 +1,28 @@ +name: update-reviewdog +on: + schedule: + - cron: '14 14 * * *' + +jobs: + reviewdog: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: reviewdog/action-depup@master + id: update-reviewdog + with: + file: action.yml + version_name: REVIEWDOG_VERSION + repo: reviewdog/reviewdog + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + title: "Update ${{ steps.update-reviewdog.outputs.repo }} to ${{ steps.update-reviewdog.outputs.latest }}" + commit-message: "Update ${{ steps.update-reviewdog.outputs.repo }} to ${{ steps.update-reviewdog.outputs.latest }}" + body: | + Update ${{ steps.update-reviewdog.outputs.repo }} to [${{ steps.update-reviewdog.outputs.latest }}](https://github.com/${{ steps.update-reviewdog.outputs.repo }}/releases/tag/v${{ steps.update-reviewdog.outputs.latest }}) + This PR is auto generated by [update-reviewdog workflow](https://github.com/${{ github.repository }}/actions?query=workflow%3A${{ github.workflow }}). + branch: update-reviewdog + base: main diff --git a/README.md b/README.md index 0bf40f0..2784689 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,18 @@ # action-phpcs A GitHub action that runs a phpcs and reports the result to reviewdog + +# Prerequisites +* Composer install has been executed +* Phpcs is install by composer and available in the composer config bin-dir +* The code styles used by phpcs are installed and confgured in .phpcs.xml + +# Usage +Add a workflow step with the action: + +```yaml +steps: + - name: Run phpcs + uses: reload/poc-phpcs-reviewdog-action@ + with: + reviewdog_token: ${{ secrets.GITHUB_TOKEN }}` +``` \ No newline at end of file diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..6123a91 --- /dev/null +++ b/action.yml @@ -0,0 +1,28 @@ +name: 'Phpcs and reviewdog runner' +description: 'This action installs reviewdog 🐶, runs phpcs 🐘 and pipes output to reviewdog. It depends ' +inputs: + reviewdog_token: + description: 'The Github API token needed for Reviewdog' +runs: + using: 'composite' + steps: + - name: Install phpcs + run: $GITHUB_ACTION_PATH/install.sh + shell: bash + env: + REVIEWDOG_VERSION: 0.10.2 + REVIEWDOG_TEMPDIR: ${{ runner.temp }} + - name: Run phpcs and report to reviewdog + run: | + set +o pipefail + phpcs --config-set ignore_errors_on_exit 1 + phpcs --config-set ignore_warnings_on_exit 1 + $(composer config bin-dir)/phpcs --report=checkstyle \ + | reviewdog -f=checkstyle -name=phpcs -reporter=github-pr-check -fail-on-error=true + shell: bash + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ inputs.reviewdog_token }} + +branding: + icon: 'terminal' + color: 'gray-dark' \ No newline at end of file diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..4501298 --- /dev/null +++ b/install.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +VERSION="${REVIEWDOG_VERSION:-latest}" + +TEMP="${REVIEWDOG_TEMPDIR}" +if [ -z "${TEMP}" ]; then + if [ -n "${RUNNER_TEMP}" ]; then + TEMP="${RUNNER_TEMP}" + else + TEMP="$(mktemp -d)" + fi +fi + +INSTALL_SCRIPT='https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh' +if [ "${VERSION}" == 'nightly' ] ; then + INSTALL_SCRIPT='https://raw.githubusercontent.com/reviewdog/nightly/master/install.sh' + VERSION='latest' +fi + +mkdir -p "${TEMP}/reviewdog/bin" + +echo '::group::🐶 Installing reviewdog ... https://github.com/reviewdog/reviewdog' +curl -sfL "${INSTALL_SCRIPT}" | sh -s -- -b "${TEMP}/reviewdog/bin" "${VERSION}" 2>&1 +echo '::endgroup::' + +echo "${TEMP}/reviewdog/bin" >>"${GITHUB_PATH}" \ No newline at end of file