-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a shared action for running a node script
This creates a new reusable GitHub workflow that can be used to run a node JS script from a repository. By script I expect it to be something that is defined inside a package.json scripts object (e.g. yarn run lint:js). It then utilises this workflow on the standardx and stylelint workflows to simplify them. The motivation for adding this was due to on govuk-chat deviating from standardx to standard and then having to define our own workflow [1]. I looked and saw other repos had also defined their own near identical workflows [2] [3] so felt the govuk-chat need was not unique. A demo of this working from a branch is available at: alphagov/govuk-chat#236 [1]: alphagov/govuk-chat@fbb629e [2]: https://github.com/alphagov/whitehall/blob/main/.github/workflows/lintjs.yml [3]: https://github.com/alphagov/whitehall/blob/main/.github/workflows/lintprettier.yml
- Loading branch information
Showing
3 changed files
with
31 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Run Node.js Script | ||
run-name: Run ${{ inputs.script }} | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
script: | ||
description: 'Script to execute (typically `yarn run <script>`)' | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
run-script: | ||
name: Run Node.js Script | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
show-progress: false | ||
|
||
- name: Setup Node | ||
uses: alphagov/govuk-infrastructure/.github/actions/setup-node@main | ||
|
||
- name: Run script | ||
run: ${{ inputs.script }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters