Skip to content

Commit

Permalink
scrtipt action
Browse files Browse the repository at this point in the history
  • Loading branch information
fmancinidtd committed Jun 21, 2024
1 parent 976325f commit a7b666c
Show file tree
Hide file tree
Showing 8 changed files with 303 additions and 17 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Hello world javascript action

This action prints "Hello World" or "Hello" + the name of a person to greet to the log.

## Inputs

### `who-to-greet`

**Required** The name of the person to greet. Default `"World"`.

## Outputs

### `time`

The time we greeted you.

## Example usage

```yaml
uses: actions/hello-world-javascript-action@e76147da8e5c81eaf017dede5645551d4b94427b
with:
who-to-greet: 'Mona the Octocat'
```
21 changes: 21 additions & 0 deletions .github/workflows/dist/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/******/ /* webpack/runtime/compat */
/******/
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = new URL('.', import.meta.url).pathname.slice(import.meta.url.match(/^file:\/\/\/\w:/) ? 1 : 0, -1) + "/";
/******/
/************************************************************************/
var __webpack_exports__ = {};
const core = require('@actions/core');
const github = require('@actions/github');

try {
// `who-to-greet` input defined in action metadata file
const nameToGreet = core.getInput('who-to-greet');
console.log(`Hello ${nameToGreet}!`);
const time = (new Date()).toTimeString();
core.setOutput("time", time);
// Get the JSON webhook payload for the event that triggered the workflow
const payload = JSON.stringify(github.context.payload, undefined, 2)
console.log(`The event payload: ${payload}`);
} catch (error) {
core.setFailed(error.message);
}
1 change: 1 addition & 0 deletions .github/workflows/dist/licenses.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dtdpa2026
3 changes: 3 additions & 0 deletions .github/workflows/dist/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
18 changes: 15 additions & 3 deletions .github/workflows/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
console.log("Running test script...");
console.log("Today is "+new Date());
console.log("...script run");
const core = require('@actions/core');
const github = require('@actions/github');

try {
// `who-to-greet` input defined in action metadata file
const nameToGreet = core.getInput('who-to-greet');
console.log(`Hello ${nameToGreet}!`);
const time = (new Date()).toTimeString();
core.setOutput("time", time);
// Get the JSON webhook payload for the event that triggered the workflow
const payload = JSON.stringify(github.context.payload, undefined, 2)
console.log(`The event payload: ${payload}`);
} catch (error) {
core.setFailed(error.message);
}
27 changes: 13 additions & 14 deletions .github/workflows/learn-github-actions.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
name: learn-github-actions
run-name: ${{ github.actor }} is learning GitHub Actions
on: [push]
jobs:
check-bats-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm install -g bats
- run: bats -v
- run: node index.js
name: 'Hello World'
description: 'Greet someone and record the time'
inputs:
who-to-greet: # id of input
description: 'Who to greet'
required: true
default: 'World'
outputs:
time: # id of output
description: 'The time we greeted you'
runs:
using: 'node20'
main: 'dist/index.js'
225 changes: 225 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
},
"type": "module",
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/github": "^6.0.0",
"@sveltejs/adapter-node": "^4.0.1",
"d3": "^7.9.0",
"moment": "^2.30.1",
Expand Down

0 comments on commit a7b666c

Please sign in to comment.