Skip to content

Commit

Permalink
feat: add bundlewatch
Browse files Browse the repository at this point in the history
  • Loading branch information
EdieLemoine committed Feb 21, 2023
1 parent 98e71d1 commit 73eacaf
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ This is a collection of reusable composite actions for GitHub Actions workflows.
- [update-tags](#update-tags)
- [compare-branches](#compare-branches)
- [Miscellaneous](#miscellaneous)
- [bundlewatch](#bundlewatch)
- [cache-nx](#cache-nx)

## General usage
Expand Down Expand Up @@ -518,6 +519,28 @@ Check if there are new commits in head that are not in base.

### Miscellaneous

#### bundlewatch

[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`.

##### Example

```yaml
- uses: myparcelnl/actions/bundlewatch@v3
with:
config: .bundlewatch.json
token: ${{ secrets.BUNDLEWATCH_TOKEN }}
```

##### Inputs

| Required | Name | Description | Example | Default |
|----------|--------|--------------------------------------|------------------------------------|---------|
| No | config | Path to the BundleWatch config file. | `.bundlewatch.json` | – |
| Yes | token | BundleWatch token to use. | `${{ secrets.BUNDLEWATCH_TOKEN }}` | – |

#### cache-nx

[Source](cache-nx/action.yml)
Expand All @@ -532,6 +555,8 @@ Save and restore the [Nx](https://nx.dev/) cache.
- uses: myparcelnl/actions/cache-nx@v3
```

[BundleWatch]: https://bundlewatch.io/

[Codecov]: https://codecov.io

[Github app]: https://docs.github.com/en/developers/apps
Expand Down
40 changes: 40 additions & 0 deletions bundlewatch/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: 'Run BundleWatch'
description: 'Check if the bundle size is within limits using BundleWatch'

inputs:
config:
description: 'The path to the BundleWatch config file'
required: false
default: ''

token:
description: 'The BundleWatch token'
required: true

runs:
using: composite
steps:
# The following was taken from:
# https://github.com/woocommerce/google-listings-and-ads/blob/ba29fbec68cc156933a8bd9d866c45e89e821428/.github/workflows/bundle-size.yml#L41-L60
- name: 'Prepare env values - push'
if: ${{ github.event_name == 'push' }}
shell: bash
run: |
BRANCH=$(echo '${{ github.event.ref }}' | sed 's/^refs\/heads\///')
echo "CI_BRANCH=$BRANCH" >> $GITHUB_ENV
echo "CI_BRANCH_BASE=$BRANCH" >> $GITHUB_ENV
echo "CI_COMMIT_SHA=${{ github.sha }}" >> $GITHUB_ENV
- name: 'Prepare env values - pull request'
if: ${{ github.event_name == 'pull_request' }}
shell: bash
run: |
echo "CI_BRANCH=${{ github.head_ref }}" >> $GITHUB_ENV
echo "CI_BRANCH_BASE=${{ github.base_ref }}" >> $GITHUB_ENV
echo "CI_COMMIT_SHA=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
- name: 'Check bundle size'
run: npx bundlewatch --config ${{ inputs.config }}
shell: bash
env:
BUNDLEWATCH_GITHUB_TOKEN: ${{ inputs.token }}

0 comments on commit 73eacaf

Please sign in to comment.