generated from actions/hello-world-javascript-action
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e0fc3db
commit 8f84d1f
Showing
4 changed files
with
74 additions
and
79 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,13 +1,13 @@ | ||
name: 'Hello World' | ||
description: 'Greet someone and record the time' | ||
name: 'Gte npm version action' | ||
description: 'Extracts the version string from the package.json file' | ||
inputs: | ||
who-to-greet: # id of input | ||
description: 'Who to greet' | ||
required: true | ||
default: 'World' | ||
file: | ||
description: 'package.json file' | ||
required: false | ||
default: 'package.json' | ||
outputs: | ||
time: # id of output | ||
description: 'The time we we greeted you' | ||
version: | ||
description: 'The version string from the package.json file' | ||
runs: | ||
using: 'node12' | ||
main: '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,15 +1,12 @@ | ||
const fs = require('fs'); | ||
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}`); | ||
const file = core.getInput('file') || 'package.json'; | ||
console.log(`Using ${file}`); | ||
const version = JSON.parse(fs.readFileSync(file)).version; | ||
console.log(version); | ||
core.setOutput("version", version); | ||
} catch (error) { | ||
core.setFailed(error.message); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.