-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from anna-money/feature/custom-target-support
Custom target support
- Loading branch information
Showing
5 changed files
with
40 additions
and
29 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 @@ | ||
.idea |
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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
FROM node:12.14.1-alpine | ||
|
||
LABEL com.github.actions.name="Arslanbekov Denis" | ||
LABEL com.github.actions.description="Run npm eslint." | ||
LABEL com.github.actions.name="NPM Target" | ||
LABEL com.github.actions.description="Run npm target." | ||
LABEL com.github.actions.icon="toggle-right" | ||
LABEL com.github.actions.color="gray-dark" | ||
LABEL homepage="https://anna.money" | ||
|
||
COPY entrypoint.sh /entrypoint.sh | ||
|
||
ENTRYPOINT ["/entrypoint.sh"] | ||
ENTRYPOINT ["/entrypoint.sh"] |
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 |
---|---|---|
@@ -1,34 +1,44 @@ | ||
# NPM eslint | ||
# NPM Target Action | ||
|
||
This GitHub Action is a utility that automatically run npm eslint. | ||
This GitHub Action runs specified target of `package.json`, default is `test`. | ||
|
||
## Configuration | ||
|
||
(For help storing this see the [GitHub docs](https://help.github.com/en/articles/creating-a-github-action).) | ||
For help storing this see the [GitHub docs](https://help.github.com/en/articles/creating-a-github-action). | ||
|
||
Next, create a new Actions workflow in your selected GitHub repository. If you don't already have a workflow file, you'll need to create a new file titled `action.yml` in the `.github/workflows` directory of your repository. Under "Edit new file", paste the following code: | ||
Create a new Actions workflow in your selected GitHub repository. If you don't already have a workflow file, | ||
you'll need to create a new file titled `action.yml` in the `.github/workflows` directory of your repository. | ||
Under "Edit new file", paste the following code: | ||
|
||
```yaml | ||
on: push | ||
name: Example Workflow | ||
jobs: | ||
runNpmEslint: | ||
name: Run NPM eslint | ||
runNpmTarget: | ||
name: Run NPM target | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Run NPM eslint | ||
uses: anna-money/github-actions-npm@v1 | ||
- name: Run NPM target | ||
uses: anna-money/github-actions-npm@v2 | ||
with: | ||
target: 'custom-target' # Remove `with` section to run default target `test` | ||
``` | ||
We strongly recommend that you update the second `uses` attribute value to reference the latest tag in the [anna-money/github-actions-npm repository](https://github.com/anna-money/github-actions-npm). This will pin your workflow to a particular version of the `anna-money/github-actions-npm` action. | ||
We strongly recommend that you update the `uses: anna-money/github-actions-npm@v2` to reference | ||
the latest tag in the [anna-money/github-actions-npm repository](https://github.com/anna-money/github-actions-npm). | ||
This will pin your workflow to a particular version of the `anna-money/github-actions-npm` action. | ||
|
||
If you already have a `action.yml` file, copy and paste the above `runNpmEslint` job declaration into the `jobs` section in your existing `action.yml` file. If you wish to verify that you've pasted the above correctly, you can go into the visual editor and ensure that there are no syntax errors. | ||
If you already have a `action.yml` file, copy and paste the above `runNpmTarget` job declaration | ||
into the `jobs` section in your existing `action.yml` file. If you wish to verify that you've | ||
pasted the above correctly, you can go into the visual editor and ensure that there are no syntax errors. | ||
|
||
As shown in the above example, the workflow should run on the `push` event. | ||
|
||
## Troubleshooting | ||
|
||
Once your workflow has been created, the best way to confirm that the workflow is executing correctly is to create a new pull request with the workflow file and verify that the newly created action succeeds. | ||
Once your workflow has been created, the best way to confirm that the workflow is executing correctly | ||
is to create a new pull request with the workflow file and verify that the newly created action succeeds. | ||
|
||
If the action fails, there may be a problem with your configuration. To investigate, dig into the action's logs to view any error messages. | ||
If the action fails, there may be a problem with your configuration. To investigate, dig into the | ||
action's logs to view any error messages. |
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 |
---|---|---|
@@ -1,12 +1,18 @@ | ||
# action.yml | ||
name: 'NPM Tests' | ||
description: 'Run npm tests' | ||
name: 'NPM Target' | ||
description: 'Run npm target' | ||
inputs: | ||
target: | ||
description: 'package.json target to run' | ||
required: true | ||
default: 'test' | ||
outputs: | ||
time: | ||
description: 'The time' | ||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' | ||
args: | ||
- ${{ inputs.target }} | ||
branding: | ||
icon: 'check-square' | ||
icon: 'check-square' | ||
color: 'orange' |
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 |
---|---|---|
@@ -1,18 +1,12 @@ | ||
#!/bin/sh -l | ||
set -e | ||
|
||
target=$1 | ||
|
||
time=$(date) | ||
echo "$time Run: npm install" | ||
npm install | ||
|
||
time=$(date) | ||
echo "$time Run: npm run eslint" | ||
npm run eslint | ||
|
||
time=$(date) | ||
echo "$time Run: npm run build --if-present" | ||
npm run build --if-present | ||
|
||
time=$(date) | ||
echo "$time Run: npm test" | ||
npm test | ||
echo "$time Run: npm run $target" | ||
npm run "$target" |