├── Dockerfile ├── action.yml ├── entrypoint.sh ├── LICENSE └── README.md /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:15.7.0 2 | 3 | COPY entrypoint.sh /entrypoint.sh 4 | 5 | RUN chmod +x /entrypoint.sh 6 | 7 | ENTRYPOINT ["/entrypoint.sh"] 8 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'Minify Action' 2 | description: 'Minify js, css, and html files pushed to a branch' 3 | runs: 4 | using: 'docker' 5 | image: 'Dockerfile' 6 | 7 | branding: 8 | icon: "minimize-2" 9 | color: "red" -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -l 2 | 3 | npm i minify@7.0.0 -g 4 | apt-get update 5 | apt-get -y install moreutils 6 | 7 | find . -type f \( -iname \*.html -o -iname \*.js -o -iname \*.css \) | while read fname 8 | do 9 | minify ${fname} | sponge ${fname} 10 | done 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Anthony Wang 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Minify Action 2 | [![GitHub release](https://img.shields.io/github/release/anthonyftwang/minify-action.svg?color=orange)](https://gitHub.com/anthonyftwang/minify-action/releases/) 3 | [![MIT license](https://img.shields.io/github/license/anthonyftwang/minify-action.svg?color=blue)](https://github.com/anthonyftwang/minify-action/blob/master/LICENSE) 4 | [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](http://makeapullrequest.com) 5 | 6 | Github Action to minify js, css, and html files pushed to a branch, using the [Minify](https://github.com/coderaiser/minify) package. 7 | ### Usage 8 | Here the target branch is `foo`. You need to checkout your repository so the Minify Action job can access it. Then, you can auto-commit the files to the repository if desired. 9 | ```yaml 10 | name: Minify Workflow 11 | on: 12 | push: 13 | branches: [ foo ] 14 | 15 | jobs: 16 | build: 17 | runs-on: ubuntu-latest 18 | steps: 19 | # Checks-out your repository 20 | - uses: actions/checkout@v2 21 | with: 22 | ref: ${{ github.ref }} 23 | 24 | - name: Minify Action 25 | uses: anthonyftwang/minify-action@v1.0.1 26 | 27 | # Auto-commit to repository 28 | - uses: stefanzweifel/git-auto-commit-action@v4 29 | with: 30 | commit_message: Minify source code 31 | branch: ${{ github.ref }} 32 | ``` 33 | --------------------------------------------------------------------------------