From b97bb857aa544ac5e02aecbe84a2ee6ec0fd91b7 Mon Sep 17 00:00:00 2001 From: illvart Date: Mon, 23 Nov 2020 06:47:27 +0700 Subject: [PATCH] first commit --- .github/FUNDING.yml | 3 +++ .github/stale.yml | 18 ++++++++++++++++ Dockerfile | 16 ++++++++++++++ LICENSE | 21 +++++++++++++++++++ README.md | 51 +++++++++++++++++++++++++++++++++++++++++++++ action.yml | 20 ++++++++++++++++++ entrypoint.sh | 3 +++ 7 files changed, 132 insertions(+) create mode 100755 .github/FUNDING.yml create mode 100644 .github/stale.yml create mode 100644 Dockerfile create mode 100644 LICENSE create mode 100644 README.md create mode 100644 action.yml create mode 100755 entrypoint.sh diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100755 index 0000000..f3dc657 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +# github: illvart +patreon: illvart +custom: ["https://www.paypal.me/illvart", "https://www.buymeacoffee.com/illvart", "https://saweria.co/illvart"] diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 0000000..9d8075f --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,18 @@ +# Number of days of inactivity before an issue becomes stale +daysUntilStale: 30 +# Number of days of inactivity before a stale issue is closed +daysUntilClose: 7 +# Issues with these labels will never be considered stale +exemptLabels: + - pinned + - accepted +# Label to use when marking an issue as stale +staleLabel: stale +# Comment to post when marking an issue as stale. Set to `false` to disable +markComment: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed in 7 days if no further activity occurs. + To prevent this from happening, leave a comment. +# Comment to post when closing a stale Issue or Pull Request. +closeComment: > + Closing this issue because it has been marked as stale for more than 7 days. diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..aed242d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM python:3.9-slim-buster + +LABEL "com.github.actions.name"="Bash shell beautifier" +LABEL "com.github.actions.description"="Run beautysh to beautify a bash shell scripts code." +LABEL "com.github.actions.icon"="code" +LABEL "com.github.actions.color"="green" + +LABEL "repository"="https://github.com/illvart/beautysh-action" +LABEL "homepage"="https://github.com/illvart/beautysh-action" +LABEL "maintainer"="illvart" + +RUN pip install beautysh + +COPY entrypoint.sh /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2792554 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 illvart + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..c6f4e8a --- /dev/null +++ b/README.md @@ -0,0 +1,51 @@ +# Bash shell beautifier + +[![Release](https://img.shields.io/github/v/release/illvart/beautysh-action?color=orange)](https://github.com/illvart/beautysh-action/releases) +[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/illvart/beautysh-action/blob/main/LICENSE) +[![Marketplace](https://img.shields.io/badge/GitHub-Marketplace-blue.svg)](https://github.com/marketplace/actions/bash-shell-beautifier) + +A GitHub Action that runs [beautysh](https://github.com/lovesegfault/beautysh) for beautify a bash shell scripts code. + +## Usage + +To use this action in your repository, create a file like `.github/workflows/ci.yml` with the following example: + +```yaml +name: CI + +on: + pull_request: + push: + branches: + - master + +jobs: + beautify: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + ref: ${{ github.head_ref }} + + - name: Run beautysh + uses: illvart/beautysh-action@latest + with: + # Pass beautysh options in args, for example: + args: '*.sh --indent-size 4' + + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: '[auto] ci: apply beautysh changes' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +``` + +If there is no `args` option it will fallback into `*.sh`. + +To avoid errors when project directory doesn't have an `*.sh` file, you can pass it with `&>/dev/null`. + +For a full list of possible `args` checkout the [beautysh docs](https://github.com/lovesegfault/beautysh#usage). diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..d98876c --- /dev/null +++ b/action.yml @@ -0,0 +1,20 @@ +name: 'Bash shell beautifier' +description: 'Run beautysh to beautify a bash shell scripts code.' +author: 'illvart' + +branding: + icon: 'code' + color: 'green' + +inputs: + args: + description: 'Arguments provided to beautysh' + required: false + default: '*.sh' + +runs: + using: 'docker' + image: 'Dockerfile' + args: + - ${{ inputs.args }} + \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..6f976f5 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,3 @@ +#!/bin/sh +set -e +sh -c "beautysh $*"