https://github.com/smashedr/js-test-action
JavaScraipt Test Action
https://github.com/smashedr/js-test-action
actions javascript
Last synced: over 1 year ago
JSON representation
JavaScraipt Test Action
- Host: GitHub
- URL: https://github.com/smashedr/js-test-action
- Owner: smashedr
- License: mit
- Created: 2023-10-31T07:39:32.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2025-02-21T09:15:07.000Z (over 1 year ago)
- Last Synced: 2025-02-21T09:39:59.906Z (over 1 year ago)
- Topics: actions, javascript
- Language: JavaScript
- Homepage: https://cssnr.github.io
- Size: 726 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/smashedr/js-test-action/actions/workflows/release.yaml)
[](https://github.com/smashedr/js-test-action/actions/workflows/test.yaml)
[](https://sonarcloud.io/summary/new_code?id=smashedr_js-test-action)
[](https://github.com/smashedr/js-test-action/releases/latest)
[](https://github.com/smashedr/js-test-action/graphs/commit-activity)
[](https://codeberg.org/shaner/js-test-action)
[](https://github.com/smashedr/js-test-action)
[](https://github.com/smashedr/js-test-action/stargazers)
[](https://cssnr.github.io/)
[](https://discord.gg/wXy6m2X8wY)
# JavaScript Test Action
- [Inputs](#Inputs)
- [Permissions](#Permissions)
- [Outputs](#Outputs)
- [Examples](#Examples)
- [Development](#Development)
This action creates or updates the provided `tag` to the `sha` has that triggered the workflow.
This includes inputs, outputs, job summary, and automatic token authentication.
## Inputs
| input | required | default | description |
| ------- | -------- | --------------------- | --------------------------- |
| tag | No | test | Tag to Create or Update |
| summary | No | true | Add Summary to Job |
| token | No | `${{ github.token }}` | Only if External Token [^1] |
📜 View Example Job Summary
---
Updated: [test](https://github.com/smashedr/js-test-action/releases/tag/test) :arrow_right: `6470ef53102d5229672433f1adb6afa42e7b64d9`
InputsInputValuetagtestsummarytrue
---
With no inputs this will create/update the tag `test`.
```yaml
- name: 'JS Test Action'
uses: smashedr/js-test-action@master
```
With all inputs. Note that `token` is NOT required.
```yaml
- name: 'JS Test Action'
uses: smashedr/js-test-action@master
with:
tag: test
summary: true
token: ${{ secrets.PAT }} # only include this if you need to use a PAT
```
### Permissions
This action requires the following permissions:
```yaml
permissions:
contents: write
```
## Outputs
| output | description |
| ------ | ----------- |
| sha | Tag Hash |
```yaml
- name: 'JS Test Action'
id: test
uses: smashedr/js-test-action@master
- name: 'Echo Output'
run: |
echo "sha: '${{ steps.test.outputs.sha }}'"
```
## Examples
```yaml
name: 'Test'
on:
workflow_dispatch:
push:
jobs:
test:
name: 'Test'
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: write
steps:
- name: 'Checkout'
uses: actions/checkout@v4
- name: 'JS Test Action'
id: test
uses: smashedr/js-test-action@master
- name: 'Echo Outputs'
run: |
echo "sha: '${{ steps.test.outputs.sha }}'"
```
# Development
A GitHub Actions Primer: https://docs.github.com/en/actions/sharing-automations/creating-actions
## Actions Overview
This is a JavaScript Action. For other types see:
- TypeScript: https://github.com/smashedr/ts-test-action
- Docker/Python: https://github.com/smashedr/py-test-action
The heart of a GitHub Action is the [action.yml](action.yml) file. This describes everything about your action.
- https://docs.github.com/en/actions/sharing-automations/creating-actions/metadata-syntax-for-github-actions
JS Actions must be fully built in the action's environment. See the `build` in [package.json](package.json) for details.
## Actions Toolkit
The toolkit contains many parts. The `@actions/core` is required and this action uses the `@actions/github` module.
- https://github.com/actions/toolkit
This also uses `github.getOctokit`.
- https://octokit.github.io/rest.js
## Local Development
To run actions locally you need to install act: https://nektosact.com/installation/index.html
```shell
npm install
npm run build:watch
act -j test
```
Alternatively, to run from source, change `main` in [action.yml](action.yml) to `src/index.js` and
run: `act -j test --use-gitignore=false`
For advanced using with things like secrets, variables and context see: https://nektosact.com/usage/index.html
You should also review the options from `act --help`
Note, the `.env`, `.secrets` and `.vars` files are automatically sourced with no extra options.
To source `event.json` you need to run act with `act -e event.json`
[^1]:
The `${{ github.token }}` / `{{ secrets.GITHUB_TOKEN }}` is automatically passed, there is no need to manually pass these!
This is only available to allow users to pass a different token they have created and defined in their `secrets`.