mirror of
https://github.com/actions/hello-world-javascript-action.git
synced 2025-12-16 15:19:19 +00:00
27 lines
784 B
JavaScript
27 lines
784 B
JavaScript
import * as core from '@actions/core'
|
|
import * as github from '@actions/github'
|
|
|
|
/**
|
|
* The main function for the action.
|
|
* @returns {Promise<void>} Resolves when the action is complete.
|
|
*/
|
|
export async function run() {
|
|
try {
|
|
// The `who-to-greet` input is defined in action metadata file
|
|
const whoToGreet = core.getInput('who-to-greet', { required: true })
|
|
core.info(`Hello, ${whoToGreet}!`)
|
|
|
|
// Get the current time and set as an output
|
|
const time = new Date().toTimeString()
|
|
core.setOutput('time', time)
|
|
|
|
// Output the payload for debugging
|
|
core.info(
|
|
`The event payload: ${JSON.stringify(github.context.payload, null, 2)}`
|
|
)
|
|
} catch (error) {
|
|
// Fail the workflow step if an error occurs
|
|
core.setFailed(error.message)
|
|
}
|
|
}
|