generated from gr2m/hello-world-js-action
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: initial version
- Loading branch information
Showing
6 changed files
with
109 additions
and
64 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
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,8 +1,8 @@ | ||
# Hello World Action | ||
# Cowsay Action | ||
|
||
> A simple GitHub Action written in JavaScript | ||
> The cowsay GitHub Action written in JavaScript | ||
[![Build Status](https://github.com/octokit/request-action/workflows/Test/badge.svg)](https://github.com/octokit/request-action/actions) | ||
[![Build Status](https://github.com/octokit/cowsay-action/workflows/Test/badge.svg)](https://github.com/octokit/cowsay-action/actions) | ||
|
||
## Usage | ||
|
||
|
@@ -17,43 +17,24 @@ jobs: | |
sayHelloWorld: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: gr2m/[email protected] | ||
``` | ||
Customize greeting | ||
```yml | ||
name: Hello world! | ||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
sayHelloWorld: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: gr2m/[email protected] | ||
- uses: gr2m/[email protected] | ||
with: | ||
greeting: Gregor | ||
text: "Hello" | ||
``` | ||
## How it works | ||
Recommended reading: The official "[Creating a JavaScript action](https://docs.github.com/en/actions/creating-actions/creating-a-javascript-action)" guide. | ||
Will log | ||
`gr2m/hello-world-js-action` does the following | ||
|
||
1. It logs a "Hello, world!" to the output | ||
2. It uses the [`@actions/core`](https://github.com/actions/toolkit/tree/main/packages/core) module to showcase how to use dependencies | ||
3. It supports a `greeting` input | ||
4. It writes the total greeting to outputs | ||
5. It uses `@vercel/ncc` to compile the code and its dependencies to a single file that can be executed as a standalone GitHub Action. | ||
|
||
The most important learning of using Node to create a GitHub Action is that you cannot require/import dependencies. When someone uses your action as part of their workflow, your action's dependencies are not automatically installed. Hence the build step using `@vercel/ncc`. | ||
|
||
**Bonus**: This action is releasing automatically to GitHub using [`semantic-release`](https://github.com/semantic-release). It also pushes updates to the `v1.x` branch, which you can reliably depend on in your GitHub workflow (`uses: gr2m/[email protected]`). If there should ever be a breaking release, I'll create a `v2.x` branch, etc. | ||
``` | ||
_______ | ||
< Hello > | ||
------- | ||
\ ^__^ | ||
\ (oo)\_______ | ||
(__)\ )\/\ | ||
||----w | | ||
|| || | ||
``` | ||
|
||
## License | ||
|
||
[MIT](LICENSE) | ||
[ISC](LICENSE) |
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,16 +1,12 @@ | ||
name: Hello, world! (JS) | ||
description: "A simple GitHub Action written in JavaScript" | ||
name: Cowsay | ||
description: "The cowsay GitHub Action written in JavaScript" | ||
branding: | ||
icon: "clipboard" | ||
color: yellow | ||
icon: "message-square" | ||
color: purple | ||
inputs: | ||
greeting: | ||
description: "Custom media type in the Accept header" | ||
required: false | ||
default: "world" | ||
outputs: | ||
greeting: | ||
description: "The full greeting text" | ||
text: | ||
description: "Thing for cow to say" | ||
required: true | ||
runs: | ||
using: "node12" | ||
main: "dist/index.js" |
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,8 +1,10 @@ | ||
const core = require("@actions/core"); | ||
const cowsay = require("cowsay"); | ||
|
||
const greeting = core.getInput("greeting"); | ||
const output = `Hello, ${greeting}!`; | ||
const text = core.getInput("text"); | ||
|
||
core.info(output); | ||
|
||
core.setOutput("greeting", output); | ||
core.info( | ||
cowsay.say({ | ||
text, | ||
}) | ||
); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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