Skip to content
This repository has been archived by the owner on Mar 6, 2021. It is now read-only.

Commit

Permalink
Enhancement: Allow specifying arguments and options
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Sep 20, 2019
1 parent 1bd80d2 commit 9fb2169
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 18 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ jobs:
- name: "Build and tag Docker image"
run: $(which docker) build --tag localheinz/composer-normalize-action ${GITHUB_WORKSPACE}

- name: "Run Docker image"
- name: "Run Docker image with default behaviour"
run: $(which docker) run --interactive --rm --workdir=/normalizer --volume ${GITHUB_WORKSPACE}/.build:/normalizer localheinz/composer-normalize-action:latest

- name: "Run Docker image with custom behaviour"
run: $(which docker) run --interactive --rm --workdir=/normalizer --volume ${GITHUB_WORKSPACE}/.build:/normalizer localheinz/composer-normalize-action:latest --indent-size=4 --indent-style=tab --no-update-lock

- name: "Docker Login"
if: "'refs/heads/master' == github.ref || startsWith('refs/tags/', github.ref)"
run: echo ${{ secrets.DOCKER_PASSWORD }} | $(which docker) login --password-stdin --username ${{ secrets.DOCKER_USERNAME }}
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## Unreleased

For a full diff see [`0.4.2...master`](https://github.com/localheinz/composer-normalize-action/compare/0.4.2...master).
For a full diff see [`0.5.0...master`](https://github.com/localheinz/composer-normalize-action/compare/0.5.0...master).

## [`0.5.0`](https://github.com/localheinz/composer-normalize-action/releases/tag/0.5.0)

For a full diff see [`0.4.2...0.5.0`](https://github.com/localheinz/composer-normalize-action/compare/0.4.2...0.5.0).


### Changed

* Started using `php:7.3-cli-alpine` instead of `php:7.3-alpine` as Docker base image ([#39](https://github.com/localheinz/composer-normalize-action/pull/39)), by [@localheinz](https://github.com/localheinz)
* Requiring `localheinz/composer-normalize` only when value of `COMPOSER_NORMALIZE_VERSION` environment variable is different from initially installed version ([#40](https://github.com/localheinz/composer-normalize-action/pull/40)), by [@localheinz](https://github.com/localheinz)
* Allow specifying arguments and options for `composer normalize` using the `args` configuration ([#47](https://github.com/localheinz/composer-normalize-action/pull/47)), by [@localheinz](https://github.com/localheinz)

## [`0.4.2`](https://github.com/localheinz/composer-normalize-action/releases/tag/0.4.2)

Expand Down
76 changes: 61 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,33 @@

## What does this action do?

This action runs [`localheinz/composer-normalize`](https://github.com/localheinz/composer-normalize) with the `--dry-run` option.

That is, when you enable this action, the action will fail when a `composer.json` is pushed that is not valid or not already normalized.
This action runs [`localheinz/composer-normalize`](https://github.com/localheinz/composer-normalize).

## Usage

Define a workflow in `.github/workflows/ci.yml` (or add a job if you already have defined workflows). Here's a basic example:
Define a workflow in `.github/workflows/ci.yml` (or add a job if you already have defined workflows).

:bulb: Read more about [Configuring a workflow](https://help.github.com/en/articles/configuring-a-workflow).


### Default Behaviour

By default this action will run

```
$ composer normalize --dry-run
```

in the working directory.

When you use this action in a step with the default behaviour, the step will fail when `composer.json`

- does not exist in this directory (be sure to checkout the code first, see [`actions/checkout`](https://github.com/actions/checkout))
- is not valid
- is not already normalized


Here's an example for a workflow configuration with the default behaviour:

```yaml
name: CI
Expand All @@ -20,14 +40,48 @@ on: push
jobs:
composer-normalize:
name: composer-normalize

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master
- name: composer-normalize-action
- name: Checkout
uses: actions/checkout@master

- name: Run composer normalize
uses: docker://localheinz/composer-normalize-action:latest
```
:bulb: Read more about [Configuring a workflow](https://help.github.com/en/articles/configuring-a-workflow).
:bulb: Here
To see this action in action, take a look at the following checks:
* https://github.com/localheinz/composer-normalize-action-example/pull/1/checks
* https://github.com/localheinz/composer-normalize-action-example/pull/2/checks
* https://github.com/localheinz/composer-normalize-action-example/pull/3/checks
### Custom Behavior
If you prefer to specify [arguments](https://github.com/localheinz/composer-normalize/tree/1.3.1#arguments) or [options](https://github.com/localheinz/composer-normalize/tree/1.3.1#options) yourself, you can configure those using the `args` option:

```yaml
name: CI
on: push
jobs:
composer-normalize:
name: composer-normalize
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
- name: Run composer normalize
uses: docker://localheinz/composer-normalize-action:latest
with:
args: ${GITHUB_WORKSPACE}/sub-directory/composer.json --dry-run
```

### Docker image

Expand Down Expand Up @@ -87,14 +141,6 @@ $ composer global require localheinz/composer-normalize:$COMPOSER_NORMALIZE_VERS
It can be any value that is understood by [`composer`](https://getcomposer.org/doc/articles/versions.md).
## Examples
To see this action in action, take a look at the following checks:
* https://github.com/localheinz/composer-normalize-action-example/pull/1/checks
* https://github.com/localheinz/composer-normalize-action-example/pull/2/checks
* https://github.com/localheinz/composer-normalize-action-example/pull/3/checks
## Changelog
Please have a look at [`CHANGELOG.md`](CHANGELOG.md).
Expand Down
8 changes: 7 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@ if [ "$HOME" != '/root' ]; then
cp -r /root/.composer "$HOME"/.composer;
fi

composer normalize --dry-run
if [ $# -eq 0 ]; then
composer normalize --dry-run

exit $?
fi

sh -c "composer normalize $*"

0 comments on commit 9fb2169

Please sign in to comment.