From 50892bedb077ed34e09953214c59d6be7be5e4b2 Mon Sep 17 00:00:00 2001 From: Jacob Date: Sun, 17 Sep 2023 16:03:41 -0500 Subject: [PATCH 1/2] Allow additional arguments to be passed to cloc --- Dockerfile | 5 ++--- action.yml | 9 ++++++++- entrypoint.sh | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5b500fd..9ef253b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,9 @@ FROM alpine:3.18 -ENTRYPOINT ["/usr/bin/dumb-init", "--"] -CMD ["/entrypoint.sh"] +ENTRYPOINT ["/usr/bin/dumb-init", "--", "/entrypoint.sh"] RUN apk add --no-cache --update cloc \ dumb-init \ git - + COPY entrypoint.sh / diff --git a/action.yml b/action.yml index 7ad679c..412d6cd 100644 --- a/action.yml +++ b/action.yml @@ -1,11 +1,18 @@ # action.yml name: 'Count Lines of Code (cloc)' description: 'Count Lines of Code with https://github.com/AlDanial/cloc' +inputs: + options: + description: 'Additional options to pass to cloc' + required: false + default: '' runs: using: 'docker' image: 'Dockerfile' - + args: + - ${{ inputs.options }} + branding: icon: 'code' color: 'blue' diff --git a/entrypoint.sh b/entrypoint.sh index a30a941..71a2bef 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,4 +1,4 @@ #!/usr/bin/env sh # Trust workspace git config --global --add safe.directory "$GITHUB_WORKSPACE" -cloc $(git rev-parse HEAD) | tee -a cloc.txt +cloc $(git rev-parse HEAD) $1 | tee -a cloc.txt From 891d3be5fb47f0bc1968748bde0d0d5f726fd95b Mon Sep 17 00:00:00 2001 From: djdefi Date: Thu, 21 Sep 2023 10:47:27 -0700 Subject: [PATCH 2/2] Test additional options in workflow --- .github/workflows/cloc.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cloc.yml b/.github/workflows/cloc.yml index 6f84ca6..a120626 100644 --- a/.github/workflows/cloc.yml +++ b/.github/workflows/cloc.yml @@ -20,10 +20,15 @@ jobs: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v4 - # Runs djdefi/cloc-action@master + # Runs djdefi/cloc-action@main - name: Count Lines of Code (cloc) uses: djdefi/cloc-action@main + - name: Count Lines of Code with additional options + uses: djdefi/cloc-action@main + with: + options: --exclude-lang=YML --md --report-file=cloc.md + #- name: Upload cloc output as a build artifact # uses: actions/upload-artifact@v2 # with: