Skip to content

Commit

Permalink
Sets up as a very basic GitHub Action
Browse files Browse the repository at this point in the history
  • Loading branch information
donatj committed Aug 17, 2023
1 parent 0006186 commit 02d1373
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM php:8.2-cli-alpine

RUN apk add --no-cache bash

ADD cs2pr /usr/local/bin
ADD action-entrypoint.sh /usr/local/bin

ENTRYPOINT ["action-entrypoint.sh"]
16 changes: 16 additions & 0 deletions action-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

set -e

FLAGS=()

[[ -n "$CS2PR_GRACEFUL_WARNINGS" ]] && FLAGS+=("--graceful-warnings")
[[ -n "$CS2PR_COLORIZE" ]] && FLAGS+=("--colorize")
[[ -n "$CS2PR_NOTICES_AS_WARNINGS" ]] && FLAGS+=("--notices-as-warnings")
[[ -n "$CS2PR_ERRORS_AS_WARNINGS" ]] && FLAGS+=("--errors-as-warnings")
[[ -n "$CS2PR_PREPEND_FILENAME" ]] && FLAGS+=("--prepend-filename")
[[ -n "$CS2PR_PREPEND_SOURCE" ]] && FLAGS+=("--prepend-source")

IFS=";" read -r -a FILES <<< "$CS2PR_FILES"

cs2pr "${FLAGS[@]}" "${FILES[@]}"
49 changes: 49 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: cs2pr
description: Convert checkstyle XML to GitHub PR annotations

inputs:
graceful-warnings:
description: Don't exit with error codes if there are only warnings
required: false
default: ""
colorize:
description: Colorize the output (still compatible with Github Annotations)
required: false
default: ""
notices-as-warnings:
description: Convert notices to warnings (Github does not annotate notices otherwise)
required: false
default: ""
errors-as-warnings:
description: Downgrade errors to warnings
required: false
default: ""
prepend-filename:
description: Prepend error 'filename' attribute to the message
required: false
default: ""
prepend-source:
description: Prepend error 'source' attribute to the message
required: false
default: ""
files:
description: The checkstyle XML files to convert to GitHub PR annotations separated by semicolons
required: true

outputs: {}

runs:
using: docker
image: Dockerfile
env:
CS2PR_GRACEFUL_WARNINGS: ${{ inputs.graceful-warnings }}
CS2PR_COLORIZE: ${{ inputs.colorize }}
CS2PR_NOTICES_AS_WARNINGS: ${{ inputs.notices-as-warnings }}
CS2PR_ERRORS_AS_WARNINGS: ${{ inputs.errors-as-warnings }}
CS2PR_PREPEND_FILENAME: ${{ inputs.prepend-filename }}
CS2PR_PREPEND_SOURCE: ${{ inputs.prepend-source }}
CS2PR_FILES: ${{ inputs.files }}

branding:
icon: "file"
color: "purple"

0 comments on commit 02d1373

Please sign in to comment.