Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Nate Allen committed Jan 7, 2020
0 parents commit 1e2590b
Showing 5 changed files with 806 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM debian:9.7-slim

RUN apt-get update \
&& apt-get install -y curl \
&& rm -rf /var/lib/apt/lists/*

RUN curl -sL https://deb.nodesource.com/setup_13.x | bash -

RUN apt-get install -y nodejs
RUN npm install -g yarn

RUN chmod +x *.sh

ENTRYPOINT ["/entrypoint.sh"]
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Build Yarn and npm

For building yarn or npm files.

### What does this repo need

* Tests and Validation
* Complete documentation for usage
17 changes: 17 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: 'Build Yarn and npm'
description: 'Builds Yarn or npm files'
author: 'Linchpin'
inputs:
working_directory:
description: 'The directory that contains the Yarn or npm files'
required: false
default: './'
outputs:
success:
description: 'Did the build happen or not?'
runs:
using: 'docker'
image: 'Dockerfile'
branding:
icon: 'package'
color: 'blue'
93 changes: 93 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/bin/bash
# If any commands fail (exit code other than 0) entire script exits
set -e

# See if our project has a gulpfile either in the root directory if it's a theme
# or in the assets/ folder if it is a plugin

composer_path="./composer.json"
build_file_path="./gulpfile.js"
bower_file_path="./bower.json"
build_type=none

# Go to the working directory (current directory by default)
cd ${working_directory:-./}

# If we have composer dependencies make sure they are installed
if [ -f "$composer_path" ]
then
echo "Composer File found. Starting composer install."
composer install
fi

if [ -f "$build_file_path" ]
then
echo "Gulpfile found. Starting build process"
build_type=gulp
else
build_file_path="./gulpfile.babel.js"
if [ -f "$build_file_path" ]
then
echo "Gulpfile w/ Babel found. Starting build process"
build_type=gulp_yarn
fi
fi

if [ "$build_type" == "none" ]
then
echo "Gulpfile not found. Searching for Gruntfile instead."
build_file_path="./Gruntfile.js"
if [ -f "$build_file_path" ]
then
echo "Gruntfile found."
build_type=grunt
else
echo "No build file found. No build needed."
fi
fi

# check to see our build type and if so build using either gulp or grunt
if [ "$build_type" != "none" ]
then
if [ "$build_type" == "gulp_yarn" ]
then
echo "Yarn Install"
yarn global add gulp-cli
yarn install

# Only build if the build:production task exists in the build path
if grep -q build:production "$build_file_path";
then
echo "Building project using gulp"
gulp build:production
fi
else
echo "Initiating NPM Install"
npm install

# Only install and fire bower if we have a bower.json
if [ -f "$bower_file_path" ]
then
echo "Initiating Bower Install"

npm install -g bower
bower install
fi

if [ $build_type = "gulp" ]
then
if grep -q build:production "$build_file_path";
then
echo "Building project using gulp"
gulp build:production
fi
else
# Make sure we have a build command within our grunt file
if grep -q build "$build_file_path";
then
echo "Building project using grunt"
grunt build
fi
fi
fi
fi

0 comments on commit 1e2590b

Please sign in to comment.