├── .github └── main.workflow ├── .gitignore ├── README.md ├── build ├── LICENSE ├── README.md ├── action.yml └── entrypoint.sh └── commit ├── LICENSE ├── README.md ├── action.yml └── entrypoint.sh /.github/main.workflow: -------------------------------------------------------------------------------- 1 | workflow "Build and Publish" { 2 | on = "push" 3 | resolves = "Docker Publish" 4 | } 5 | 6 | action "Shell Lint" { 7 | uses = "actions/bin/shellcheck@master" 8 | args = "entrypoint.sh" 9 | } 10 | 11 | action "Test" { 12 | uses = "actions/bin/bats@master" 13 | args = "test/*.bats" 14 | } 15 | 16 | action "Docker Lint" { 17 | uses = "docker://replicated/dockerfilelint" 18 | args = ["Dockerfile"] 19 | } 20 | 21 | action "Build" { 22 | needs = ["Shell Lint", "Test", "Docker Lint"] 23 | uses = "actions/docker/cli@master" 24 | args = "build -t npm ." 25 | } 26 | 27 | action "Docker Tag" { 28 | needs = ["Build"] 29 | uses = "actions/docker/tag@master" 30 | args = "npm github/npm --no-latest" 31 | } 32 | 33 | action "Publish Filter" { 34 | needs = ["Build"] 35 | uses = "actions/bin/filter@master" 36 | args = "branch master" 37 | } 38 | 39 | action "Docker Login" { 40 | needs = ["Publish Filter"] 41 | uses = "actions/docker/login@master" 42 | secrets = ["DOCKER_USERNAME", "DOCKER_PASSWORD"] 43 | } 44 | 45 | action "Docker Publish" { 46 | needs = ["Docker Tag", "Docker Login"] 47 | uses = "actions/docker/cli@master" 48 | args = "push github/npm" 49 | } 50 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GitHub Actions for JavaScript build tools (Gulp, Grunt, NPM -- and git) 2 | 3 | Run JS build tasks with Gulp, Grunt or NPM, then commit any changed files and push them back to your original repository. 4 | 5 | Perfect for Grunt or Gulp tasks that do CSS (or SASS/LESS) compilation or JS transpilation. If your build task changes files, these actions are for you. 6 | 7 | This repository contains two actions that may be used independently -- typically one after another: 8 | 9 | - **build** (elstudio/actions-js-build/build@v4): Looks for a gulpfile.js or Gruntfile.js in the working directory, then installs any required npm packages and runs the appropriate build tool. If it finds neither gulp or grunt, the script runs npm. Set the workflow `args` arguments to run the tasks of your choice. 10 | - **commit** (elstudio/actions-js-build/commit@v4): Commits any file changes, and pushes them back to the current branch of the origin repository on GitHub. 11 | 12 | 13 | ## Usage 14 | 15 | An example workflow to run `grunt default` task to build, test, then commit and push any changes back to the GitHub origin repository: 16 | 17 | ```yaml 18 | name: Grunt build and commit updated stylesheets 19 | 20 | on: [push] 21 | 22 | jobs: 23 | grunt-build: 24 | 25 | runs-on: ubuntu-latest 26 | 27 | steps: 28 | - uses: actions/checkout@v2 29 | - uses: actions/setup-node@v2 30 | with: 31 | node-version: 12 32 | 33 | - name: Compile with Grunt 34 | uses: elstudio/actions-js-build/build@v4 35 | with: 36 | wdPath: './web/themes/nw8' 37 | 38 | - name: Commit changes 39 | uses: elstudio/actions-js-build/commit@v4 40 | with: 41 | commitMessage: Regenerate css 42 | ``` 43 | 44 | 45 | 46 | ### Inputs 47 | 48 | * `wdPath` - **Optional**. To specify a directory other than the repository root where NPM's Package.json and either gulpfile.js or Gruntfile.js may be found. 49 | -------------------------------------------------------------------------------- /build/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2019-2021 Eric Johnson and contributors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /build/README.md: -------------------------------------------------------------------------------- 1 | # GitHub Actions for JavaScript build tools (Gulp, Grunt or NPM) 2 | 3 | Run JS build tasks with Gulp, Grunt or NPM. 4 | 5 | Perfect for Grunt tasks that do CSS (or SASS/LESS) compilation or JavaScript transpilation. 6 | 7 | - **build** (elstudio/actions-js-build/build@v4): Looks for a gulpfile.js or Gruntfile.js in the working directory, then installs any required npm packages and runs the build tool. If it finds neither gulp or grunt, the script runs npm. Set the workflow `args` arguments to run the tasks of your choice. 8 | 9 | This Action for [npm](https://www.npmjs.com/) installs any required npm packages, then installs and runs any installed JavaScript build tools -- currently either Gulp or Grunt. 10 | 11 | ## Usage 12 | 13 | An example workflow to run the `grunt default` task to build, test. The second action commits and pushes any changes back to the GitHub origin repository: 14 | 15 | 16 | ```yaml 17 | name: Grunt build and commit updated stylesheets 18 | 19 | on: [push] 20 | 21 | jobs: 22 | grunt-build: 23 | 24 | runs-on: ubuntu-latest 25 | 26 | steps: 27 | - uses: actions/checkout@v2 28 | - uses: actions/setup-node@v2 29 | with: 30 | node-version: 12 31 | - name: Compile with Grunt 32 | uses: elstudio/actions-js-build/build@v4 33 | with: 34 | wdPath: './web/themes/nw8' 35 | 36 | - name: Commit changes 37 | uses: elstudio/actions-js-build/commit@v4 38 | with: 39 | commitMessage: Regenerate css 40 | ``` 41 | 42 | 43 | ### Inputs 44 | 45 | * `wdPath` - **Optional**. To specify a directory other than the repository root where NPM's Package.json and either gulpfile.js or Gruntfile.js may be found. 46 | -------------------------------------------------------------------------------- /build/action.yml: -------------------------------------------------------------------------------- 1 | name: 'GitHub Action to execute javascript build tools' 2 | description: 'Executes npm install, followed by gulp or grunt (whichever has a build file).' 3 | author: 'elstudio' 4 | branding: 5 | icon: 'truck' 6 | color: 'purple' 7 | inputs: 8 | wdPath: 9 | description: 'Working directory path' 10 | required: false 11 | default: '' 12 | debug: 13 | description: 'Print script debugging info' 14 | required: false 15 | default: 'false' 16 | runs: 17 | using: 'composite' 18 | steps: 19 | - run: ${{ github.action_path }}/entrypoint.sh 20 | shell: bash 21 | env: 22 | DEBUG: ${{ inputs.debug }} 23 | WD_PATH: ${{ inputs.wdPath }} 24 | -------------------------------------------------------------------------------- /build/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "$DEBUG" == "false" ] 4 | then 5 | # Carry on, but do quit on errors 6 | set -e 7 | else 8 | # Verbose debugging 9 | # set -exuo pipefail 10 | export LOG_LEVEL=debug 11 | export ACTIONS_STEP_DEBUG=true 12 | fi 13 | 14 | 15 | if [ ! -z "$WD_PATH" ] 16 | then 17 | echo "Changing dir to $WD_PATH" 18 | cd $WD_PATH 19 | fi 20 | 21 | echo "Installing NPM dependencies" 22 | npm install 23 | 24 | # First try Gulp, then try Grunt 25 | # Gulpfile.js can be a file or a directory: 26 | if [ -e "gulpfile.js" ] 27 | then 28 | npm install -g gulp-cli 29 | echo "Running Gulp with args" 30 | sh -c "gulp $*" 31 | # Gruntfile can be js or coffeescript file 32 | elif [ -f "Gruntfile.js" -o -f "Gruntfile.coffee" ] 33 | then 34 | npm install -g grunt-cli 35 | echo "Running Grunt with args" 36 | sh -c "grunt $*" 37 | else 38 | echo "Running NPM with args" 39 | sh -c "npm $*" 40 | fi 41 | -------------------------------------------------------------------------------- /commit/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2019-2021 Eric Johnson and contributors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /commit/README.md: -------------------------------------------------------------------------------- 1 | # GitHub Action for Git commit 2 | 3 | This Action for git commits any changed files and pushes those changes back to the origin repository. 4 | 5 | **V3 or later of this action (elstudio/actions-js-build/commit@v4) requires actions/checkout@v2 or later.** 6 | 7 | ## Usage 8 | 9 | An example workflow to commit and push any changes back to the GitHub origin repository: 10 | 11 | 12 | ```yaml 13 | name: Grunt build and commit updated stylesheets 14 | 15 | on: [push] 16 | 17 | jobs: 18 | grunt-build: 19 | 20 | runs-on: ubuntu-latest 21 | 22 | steps: 23 | - uses: actions/checkout@v2 24 | - uses: actions/setup-node@v2 25 | with: 26 | node-version: 12 27 | 28 | - name: Compile with Grunt 29 | uses: elstudio/actions-js-build/build@4 30 | with: 31 | wdPath: './web/themes/nw8' 32 | 33 | - name: Commit changes 34 | uses: elstudio/actions-js-build/commit@v4 35 | with: 36 | commitMessage: Regenerate css 37 | ``` 38 | 39 | ### Inputs 40 | 41 | * `commitMessage` - **Optional**. Git Commit Message. Defaults to "Regenerate build artifacts." 42 | * `wdPath` - **Optional**. To specify a directory other than the repository root to check for changed files. 43 | 44 | -------------------------------------------------------------------------------- /commit/action.yml: -------------------------------------------------------------------------------- 1 | name: 'GitHub Action for git commit' 2 | description: 'Commits any changed files and pushes the result back to origin branch.' 3 | author: 'elstudio' 4 | branding: 5 | icon: 'git-commit' 6 | color: 'green' 7 | inputs: 8 | wdPath: 9 | description: 'Working directory path' 10 | required: false 11 | default: '' 12 | debug: 13 | description: 'Print script debugging info' 14 | required: false 15 | default: 'false' 16 | commitMessage: 17 | description: 'Message to log for this commit' 18 | required: false 19 | default: 'Regenerate build artifacts.' 20 | runs: 21 | using: 'composite' 22 | steps: 23 | - run: ${{ github.action_path }}/entrypoint.sh 24 | shell: bash 25 | env: 26 | DEBUG: ${{ inputs.debug }}git 27 | WD_PATH: ${{ inputs.wdPath }} 28 | COMMIT_MESSAGE: ${{ inputs.commitMessage }} 29 | -------------------------------------------------------------------------------- /commit/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## This GitHub Action for git commits any changed files and pushes 3 | ## those changes back to the origin repository. 4 | ## 5 | ## Required environment variable: 6 | ## - $GITHUB_TOKEN: The token to use for authentication with GitHub 7 | ## to commit and push changes back to the origin repository. 8 | ## 9 | ## Optional environment variables: 10 | ## - $WD_PATH: Working directory to CD into before checking for changes 11 | ## - $PUSH_BRANCH: Remote branch to push changes to 12 | 13 | if [ "$DEBUG" == "false" ] 14 | then 15 | # Carry on, but do quit on errors 16 | set -e 17 | else 18 | # Verbose debugging 19 | # set -exuo pipefail 20 | export LOG_LEVEL=debug 21 | export ACTIONS_STEP_DEBUG=true 22 | fi 23 | 24 | # If WD_PATH is defined, then cd to it 25 | if [ ! -z "$WD_PATH" ] 26 | then 27 | echo "Changing dir to $WD_PATH" 28 | cd "$WD_PATH" 29 | fi 30 | 31 | # Set up .netrc file with GitHub credentials 32 | git_setup ( ) { 33 | # Git requires our "name" and email address -- use GitHub handle 34 | git config user.email "$GITHUB_ACTOR@users.noreply.github.com" 35 | git config user.name "$GITHUB_ACTOR" 36 | } 37 | 38 | # This section only runs if there have been file changes 39 | echo "Checking for uncommitted changes in the git working tree." 40 | if expr $(git status --porcelain | wc -l) \> 0 41 | then 42 | git_setup 43 | git add . 44 | git commit -m "$COMMIT_MESSAGE" 45 | git push 46 | else 47 | echo "Working tree clean. Nothing to commit." 48 | fi 49 | --------------------------------------------------------------------------------