Skip to content

Commit

Permalink
feat: add more actions
Browse files Browse the repository at this point in the history
  • Loading branch information
EdieLemoine committed Dec 7, 2021
1 parent 244695f commit 8fcc6e5
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 8 deletions.
60 changes: 57 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,72 @@

This is a collection of reusable composite actions for GitHub Actions workflows.

## npm-install
## setup-node

1. Sets up node@14
- You can change the version by passing `node-version`.

### Example

```yaml
- name:
uses: myparcelnl/actions/setup-node@v1
with:
node-version: 16
```


## yarn-install

1. Runs [setup-node]
2. Handles cache
3. Runs `yarn install --frozen-lockfile`

### Example

```yaml
- uses: myparcelnl/actions/yarn-install@v1
with:
node-version: 16
```

## npm-install

1. Runs [setup-node]
2. Handles cache
3. Runs `npm ci`

### Example

```yaml
- name:
uses: myparcelnl/actions/npm-install
- uses: myparcelnl/actions/npm-install@v1
with:
node-version: 16
```

## composer-install

1. Sets up php@7.2 with composer v2
- You can change the php version by passing `php-version`.
- You can change the composer version or install any other tools by passing `tools`.
- See [shivammathur/setup-php](https://github.com/shivammathur/setup-php#wrench-tools-support) for supported
values.
2. Handles cache
3. Runs `composer install --no-interaction --no-progress`
- By default, it uses these additional flags: `--no-dev --no-plugins --no-scripts --optimize-autoloader`, you can
customize these by passing the `flags` option.

### Example

```yaml
- uses: myparcelnl/actions/composer-install@v1
with:
php-version: '8.0'
tools: 'composer:v2, phpunit'
flags: '--dev --optimize-autoloader'
```

[composer-install]: #composer-install
[npm-install]: #npm-install
[setup-node]: #setup-node
[yarn-install]: #yarn-install
46 changes: 46 additions & 0 deletions composer-install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: 'Set up PHP'
description: 'Set up PHP and install composer dependencies from scratch or from cache'

inputs:
php-version:
description: 'The php version to use.'
default: '7.2'
required: false

tools:
description: 'Tools to pass to shivammathur/setup-php.'
default: 'composer:v2'
required: false

flags:
description: 'Flags to use when installing composer dependencies.'
default: '--no-interaction --no-progress'
required: false

runs:
using: composite
steps:
- name: 'Set up PHP'
uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.php-version }}
tools: ${{ inputs.tools }}

- name: 'Get Composer cache directory'
shell: bash
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: 'Handle Composer cache'
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: 'Install composer dependencies'
shell: bash
run: |
composer install ${{ inputs.flags }}
8 changes: 3 additions & 5 deletions npm-install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,16 @@ inputs:
runs:
using: composite
steps:
- uses: actions/setup-node@v2
with:
node-version: ${{ inputs.node-version }}
- uses: myparcelnl/actions/setup-node@v1

- name: Prepare npm cache
- name: 'Prepare npm cache'
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install npm dependencies
- name: 'Install npm dependencies'
run: npm ci
shell: bash
16 changes: 16 additions & 0 deletions setup-node/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: 'Setup Node'
description: 'Setup Node'

inputs:
node-version:
description: 'The Node.js version to use'
default: '14'
required: false

runs:
using: composite
steps:
- name: 'Setup Node'
uses: actions/setup-node@v2
with:
node-version: ${{ inputs.node-version }}
25 changes: 25 additions & 0 deletions yarn-install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Install yarn dependencies
description: Install yarn dependencies from scratch or from cache

runs:
using: composite
steps:
- uses: myparcelnl/actions/setup-node@v1

- name: 'Get yarn cache directory path'
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
shell: bash

- name: 'Prepare yarn cache'
uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: 'Install yarn dependencies'
run: yarn install --frozen-lockfile
shell: bash

0 comments on commit 8fcc6e5

Please sign in to comment.