Skip to content

Commit

Permalink
feat: add composer-update
Browse files Browse the repository at this point in the history
  • Loading branch information
EdieLemoine committed Aug 8, 2023
1 parent a65ea34 commit 1f13797
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 18 deletions.
54 changes: 43 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,17 +287,41 @@ Can be used with Yarn 1 and Yarn 2 (berry).

##### Inputs

| Required | Name | Description | Example | Default |
| -------- | ------------- | ---------------------------------------------- | -------------- | ------- |
| No | `php-version` | The PHP version to use | `8.0` | `7.2` |
| No | `flags` | Additional flags to pass to `composer install` | `--no-scripts` ||
| Required | Name | Description | Example | Default |
| -------- | ------------- | ---------------------------------------------- | -------------- | --------------------------- |
| No | `command` | The command to run | `update` | `install` |
| No | `flags` | Additional flags to pass to `composer install` | `--no-scripts` | `--no-scripts --no-plugins` |
| No | `php-version` | The PHP version to use | `8.0` | `7.2` |

#### Outputs

| Name | Description | Example |
| ------- | ------------------------------------------------------------------------------------- | ------------------------------------------ |
| `image` | The image name that was used to install dependencies. Can be used in subsequent jobs. | `ghcr.io/myparcelnl/php-xd:7.4-cli-alpine` |

#### composer-update

[Source](composer-update/action.yml)

1. Runs [composer-install] with `command: update`.

##### Example

```yaml
- uses: myparcelnl/actions/composer-update@v3
with:
php-version: '8.0'
flags: --no-dev --no-plugins
```

##### Inputs

Same as [composer-install].

##### Outputs

Same as [composer-install].

### Testing

#### update-coverage
Expand Down Expand Up @@ -401,7 +425,8 @@ jobs using a registry.

[Source](pull-docker-image/action.yml)

Pulls and caches a docker image. Outputs the image name that was input to provide an easy way to not have to repeat the image name in the rest of your workflow.
Pulls and caches a docker image. Outputs the image name that was input to provide an easy way to not have to repeat the
image name in the rest of your workflow.

##### Inputs

Expand Down Expand Up @@ -433,7 +458,8 @@ Pulls and caches a docker image. Outputs the image name that was input to provid

[Source](semantic-release/action.yml)

Run [semantic-release]. Requires npm dependencies to be installed. Outputs information on the release that was just made (or not).
Run [semantic-release]. Requires npm dependencies to be installed. Outputs information on the release that was just
made (or not).

##### Inputs

Expand Down Expand Up @@ -599,7 +625,8 @@ Check if there are new commits in head that are not in base.

[Source](get-github-token/action.yml)

Gets a GitHub token to use in the workflow. If `token` is passed, it will be used. Otherwise, an app token will be generated. Either `token` or `app-id` and `private-key` must be passed.
Gets a GitHub token to use in the workflow. If `token` is passed, it will be used. Otherwise, an app token will be
generated. Either `token` or `app-id` and `private-key` must be passed.

Meant for use within other actions, because obviously you could just use the `token` input directly.

Expand Down Expand Up @@ -673,12 +700,15 @@ Label a pull request based on the review state. For use with the `pull_request_r

1. Gets the amount of reviews needed.
- Uses `inputs.reviews-required` if passed.
- If this input does not exist, the action will get the data via branch protections. You'll need an app or access token with the `read settings` permission for this.
- If this input does not exist, the action will get the data via branch protections. You'll need an app or access
token with the `read settings` permission for this.
2. Calculates whether the PR is approved or changes are requested.
3. Labels the PR accordingly, removing labels that are no longer relevant.
- If the PR is approved: `inputs.label-approved` is added, `inputs.label-changes-requested` is removed if it exists.
- If changes are requested: `inputs.label-changes-requested` is added, `inputs.label-approved` is removed if it exists.
- If the PR is not approved and no changes are requested: `inputs.label-approved` and `inputs.label-changes-requested` are removed if they exist.
- If changes are requested: `inputs.label-changes-requested` is added, `inputs.label-approved` is removed if it
exists.
- If the PR is not approved and no changes are requested: `inputs.label-approved`
and `inputs.label-changes-requested` are removed if they exist.

##### Example

Expand Down Expand Up @@ -750,7 +780,8 @@ Validate the title of a pull request based on the conventional commit format. Fo

[Source](bundlewatch/action.yml)

Run [BundleWatch] to check the size of your bundles. You will need to provide a [BundleWatch token] and a configuration. If you don't pass the `config` input, it will look for the `bundlewatch` key in your `package.json`.
Run [BundleWatch] to check the size of your bundles. You will need to provide a [BundleWatch token] and a configuration.
If you don't pass the `config` input, it will look for the `bundlewatch` key in your `package.json`.

##### Example

Expand Down Expand Up @@ -791,6 +822,7 @@ Save and restore the [Nx](https://nx.dev/) cache.
[build-docker-image]: #build-docker-image
[codecov/codecov-action]: https://github.com/codecov/codecov-action
[composer-install]: #composer-install
[composer-update]: #composer-update
[npm-install]: #npm-install
[pnpm-install]: #pnpm-install
[semantic-release]: #semantic-release
Expand Down
19 changes: 12 additions & 7 deletions composer-install/action.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
name: 'Set up PHP'
description: 'Set up PHP and install composer dependencies from scratch or from cache'
name: 'Install composer dependencies'
description: 'Set up PHP and install composer dependencies'

inputs:
php-version:
description: 'The php version to use.'
default: '7.2'
command:
description: 'The composer command to run.'
required: false
default: 'install'

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

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

outputs:
image:
Expand Down Expand Up @@ -55,4 +60,4 @@ runs:
--volume $PWD:/app \
--env COMPOSER_CACHE_DIR=/root/.composer \
${{ steps.prepare.outputs.image }} \
composer install --no-interaction --no-progress ${{ inputs.flags }} --no-scripts --no-plugins
composer ${{ inputs.command }} --no-interaction --no-progress ${{ inputs.flags }}
33 changes: 33 additions & 0 deletions composer-update/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: 'Update composer dependencies'
description: 'Set up PHP and update composer dependencies'

inputs:
command:
description: 'The composer command to run.'
required: false
default: 'install'

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

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

outputs:
image:
description: 'The image name that was used to install dependencies. Can be used in subsequent jobs.'
value: ${{ steps.install.outputs.image }}

runs:
using: composite
steps:
- uses: myparcelnl/actions/composer-install@v3
id: install
with:
command: ${{ inputs.command }}
flags: ${{ inputs.flags }}
image: ${{ steps.prepare.outputs.image }}

0 comments on commit 1f13797

Please sign in to comment.