{"name":"@actions/core","version":"3.0.0","keywords":["github","actions","core"],"license":"MIT","_id":"@actions/core@3.0.0","maintainers":[{"name":"chrispat","email":"chrispat@github.com"},{"name":"bryanmacfarlane","email":"bryanmacf@gmail.com"},{"name":"thboop","email":"thboop@github.com"},{"name":"konradpabjan","email":"konradpabjan@github.com"},{"name":"bdehamer","email":"brian@dehamer.com"},{"name":"joshmgross","email":"joshmgross@github.com"}],"homepage":"https://github.com/actions/toolkit/tree/main/packages/core","bugs":{"url":"https://github.com/actions/toolkit/issues"},"dist":{"shasum":"89cb07c119e9b46a649ad5f355e77de9b3108cf8","tarball":"http://registry-npm.ywwl.com/@actions/core/download/@actions/core-3.0.0.tgz","fileCount":27,"integrity":"sha512-zYt6cz+ivnTmiT/ksRVriMBOiuoUpDCJJlZ5KPl2/FRdvwU3f7MPh9qftvbkXJThragzUZieit2nyHUyw53Seg==","signatures":[{"sig":"MEQCIAQRN0D8DTQN8iDGQUfuPeO7LWfKo3ThBpo1uwgYFZbHAiBAGtLnXyoBSvfYtpNxVvrVg0+kjD8l2KtYOvMEFZmucQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@actions%2fcore@3.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":86197,"size":23249,"noattachment":false,"key":"/@actions/core/-/@actions/core-3.0.0.tgz"},"main":"lib/core.js","type":"module","_from":"file:actions-core-3.0.0.tgz","types":"lib/core.d.ts","exports":{".":{"types":"./lib/core.d.ts","import":"./lib/core.js"}},"scripts":{"tsc":"tsc -p tsconfig.json","test":"echo \"Error: run tests from root\" && exit 1","audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:d49e114d-3f19-48e2-bda9-9f40d11953f0"}},"_resolved":"/Users/runner/work/toolkit/toolkit/actions-core-3.0.0.tgz","_integrity":"sha512-zYt6cz+ivnTmiT/ksRVriMBOiuoUpDCJJlZ5KPl2/FRdvwU3f7MPh9qftvbkXJThragzUZieit2nyHUyw53Seg==","repository":{"url":"git+https://github.com/actions/toolkit.git","type":"git","directory":"packages/core"},"_npmVersion":"11.6.2","description":"Actions core lib","directories":{"lib":"lib","test":"__tests__"},"_nodeVersion":"24.13.0","dependencies":{"@actions/exec":"^3.0.0","@actions/http-client":"^4.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"@types/node":"^25.1.0"},"_npmOperationalInternal":{"tmp":"tmp/core_3.0.0_1769651706544_0.17536219287055066","host":"s3://npm-registry-packages-npm-production"},"readme":"# `@actions/core`\n\n> Core functions for setting results, logging, registering secrets and exporting variables across actions\n\n## Usage\n\n### Import the package\n\n```js\n// javascript\nconst core = require('@actions/core');\n\n// typescript\nimport * as core from '@actions/core';\n```\n\n#### Inputs/Outputs\n\nAction inputs can be read with `getInput` which returns a `string` or `getBooleanInput` which parses a boolean based on the [yaml 1.2 specification](https://yaml.org/spec/1.2/spec.html#id2804923). If `required` is set to be false, the input should have a default value in `action.yml`.\n\nOutputs can be set with `setOutput` which makes them available to be mapped into inputs of other actions to ensure they are decoupled.\n\n```js\nconst myInput = core.getInput('inputName', { required: true });\nconst myBooleanInput = core.getBooleanInput('booleanInputName', { required: true });\nconst myMultilineInput = core.getMultilineInput('multilineInputName', { required: true });\ncore.setOutput('outputKey', 'outputVal');\n```\n\n#### Exporting variables\n\nSince each step runs in a separate process, you can use `exportVariable` to add it to this step and future steps environment blocks.\n\n```js\ncore.exportVariable('envVar', 'Val');\n```\n\n#### Setting a secret\n\nSetting a secret registers the secret with the runner to ensure it is masked in logs.\n\n```js\ncore.setSecret('myPassword');\n```\n\n#### PATH Manipulation\n\nTo make a tool's path available in the path for the remainder of the job (without altering the machine or containers state), use `addPath`.  The runner will prepend the path given to the jobs PATH.\n\n```js\ncore.addPath('/path/to/mytool');\n```\n\n#### Exit codes\n\nYou should use this library to set the failing exit code for your action.  If status is not set and the script runs to completion, that will lead to a success.\n\n```js\nconst core = require('@actions/core');\n\ntry {\n  // Do stuff\n}\ncatch (err) {\n  // setFailed logs the message and sets a failing exit code\n  core.setFailed(`Action failed with error ${err}`);\n}\n```\n\nNote that `setNeutral` is not yet implemented in actions V2 but equivalent functionality is being planned.\n\n#### Logging\n\nFinally, this library provides some utilities for logging. Note that debug logging is hidden from the logs by default. This behavior can be toggled by enabling the [Step Debug Logs](../../docs/action-debugging.md#step-debug-logs).\n\n```js\nconst core = require('@actions/core');\n\nconst myInput = core.getInput('input');\ntry {\n  core.debug('Inside try block');\n  \n  if (!myInput) {\n    core.warning('myInput was not set');\n  }\n  \n  if (core.isDebug()) {\n    // curl -v https://github.com\n  } else {\n    // curl https://github.com\n  }\n\n  // Do stuff\n  core.info('Output to the actions build log')\n\n  core.notice('This is a message that will also emit an annotation')\n}\ncatch (err) {\n  core.error(`Error ${err}, action may still succeed though`);\n}\n```\n\nThis library can also wrap chunks of output in foldable groups.\n\n```js\nconst core = require('@actions/core')\n\n// Manually wrap output\ncore.startGroup('Do some function')\ndoSomeFunction()\ncore.endGroup()\n\n// Wrap an asynchronous function call\nconst result = await core.group('Do something async', async () => {\n  const response = await doSomeHTTPRequest()\n  return response\n})\n```\n\n#### Annotations\n\nThis library has 3 methods that will produce [annotations](https://docs.github.com/en/rest/reference/checks#create-a-check-run). \n```js\ncore.error('This is a bad error, action may still succeed though.')\n\ncore.warning('Something went wrong, but it\\'s not bad enough to fail the build.')\n\ncore.notice('Something happened that you might want to know about.')\n```\n\nThese will surface to the UI in the Actions page and on Pull Requests. They look something like this:\n\n![Annotations Image](../../docs/assets/annotations.png)\n\nThese annotations can also be attached to particular lines and columns of your source files to show exactly where a problem is occuring. \n\nThese options are: \n```typescript\nexport interface AnnotationProperties {\n  /**\n   * A title for the annotation.\n   */\n  title?: string\n\n  /**\n   * The name of the file for which the annotation should be created.\n   */\n  file?: string\n\n  /**\n   * The start line for the annotation.\n   */\n  startLine?: number\n\n  /**\n   * The end line for the annotation. Defaults to `startLine` when `startLine` is provided.\n   */\n  endLine?: number\n\n  /**\n   * The start column for the annotation. Cannot be sent when `startLine` and `endLine` are different values.\n   */\n  startColumn?: number\n\n  /**\n   * The end column for the annotation. Cannot be sent when `startLine` and `endLine` are different values.\n   * Defaults to `startColumn` when `startColumn` is provided.\n   */\n  endColumn?: number\n}\n```\n\n#### Styling output\n\nColored output is supported in the Action logs via standard [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code). 3/4 bit, 8 bit and 24 bit colors are all supported.\n\nForeground colors:\n\n```js\n// 3/4 bit\ncore.info('\\u001b[35mThis foreground will be magenta')\n\n// 8 bit\ncore.info('\\u001b[38;5;6mThis foreground will be cyan')\n\n// 24 bit\ncore.info('\\u001b[38;2;255;0;0mThis foreground will be bright red')\n```\n\nBackground colors:\n\n```js\n// 3/4 bit\ncore.info('\\u001b[43mThis background will be yellow');\n\n// 8 bit\ncore.info('\\u001b[48;5;6mThis background will be cyan')\n\n// 24 bit\ncore.info('\\u001b[48;2;255;0;0mThis background will be bright red')\n```\n\nSpecial styles:\n\n```js\ncore.info('\\u001b[1mBold text')\ncore.info('\\u001b[3mItalic text')\ncore.info('\\u001b[4mUnderlined text')\n```\n\nANSI escape codes can be combined with one another:\n\n```js\ncore.info('\\u001b[31;46mRed foreground with a cyan background and \\u001b[1mbold text at the end');\n```\n\n> Note: Escape codes reset at the start of each line\n\n```js\ncore.info('\\u001b[35mThis foreground will be magenta')\ncore.info('This foreground will reset to the default')\n```\n\nManually typing escape codes can be a little difficult, but you can use third party modules such as [ansi-styles](https://github.com/chalk/ansi-styles).\n\n```js\nconst style = require('ansi-styles');\ncore.info(style.color.ansi16m.hex('#abcdef') + 'Hello world!')\n```\n\n#### Action state\n\nYou can use this library to save state and get state for sharing information between a given wrapper action:\n\n**action.yml**:\n\n```yaml\nname: 'Wrapper action sample'\ninputs:\n  name:\n    default: 'GitHub'\nruns:\n  using: 'node12'\n  main: 'main.js'\n  post: 'cleanup.js'\n```\n\nIn action's `main.js`:\n\n```js\nconst core = require('@actions/core');\n\ncore.saveState(\"pidToKill\", 12345);\n```\n\nIn action's `cleanup.js`:\n\n```js\nconst core = require('@actions/core');\n\nvar pid = core.getState(\"pidToKill\");\n\nprocess.kill(pid);\n```\n\n#### OIDC Token\n\nYou can use these methods to interact with the GitHub OIDC provider and get a JWT ID token which would help to get access token from third party cloud providers.\n\n**Method Name**: getIDToken()\n\n**Inputs**\n\naudience : optional\n\n**Outputs**\n\nA [JWT](https://jwt.io/) ID Token\n\nIn action's `main.ts`:\n```js\nconst core = require('@actions/core');\nasync function getIDTokenAction(): Promise<void> {\n  \n   const audience = core.getInput('audience', {required: false})\n   \n   const id_token1 = await core.getIDToken()            // ID Token with default audience\n   const id_token2 = await core.getIDToken(audience)    // ID token with custom audience\n   \n   // this id_token can be used to get access token from third party cloud providers\n}\ngetIDTokenAction()\n```\n\nIn action's `actions.yml`:\n\n```yaml\nname: 'GetIDToken'\ndescription: 'Get ID token from Github OIDC provider'\ninputs:\n  audience:  \n    description: 'Audience for which the ID token is intended for'\n    required: false\noutputs:\n  id_token1: \n    description: 'ID token obtained from OIDC provider'\n  id_token2: \n    description: 'ID token obtained from OIDC provider'\nruns:\n  using: 'node12'\n  main: 'dist/index.js'\n```\n\n#### Filesystem path helpers\n\nYou can use these methods to manipulate file paths across operating systems.\n\nThe `toPosixPath` function converts input paths to Posix-style (Linux) paths.\nThe `toWin32Path` function converts input paths to Windows-style paths. These\nfunctions work independently of the underlying runner operating system.\n\n```js\ntoPosixPath('\\\\foo\\\\bar') // => /foo/bar\ntoWin32Path('/foo/bar') // => \\foo\\bar\n```\n\nThe `toPlatformPath` function converts input paths to the expected value on the runner's operating system.\n\n```js\n// On a Windows runner.\ntoPlatformPath('/foo/bar') // => \\foo\\bar\n\n// On a Linux runner.\ntoPlatformPath('\\\\foo\\\\bar') // => /foo/bar\n```\n\n#### Platform helper\n\nProvides shorthands for getting information about platform action is running on.\n\n```js\nimport { platform } from '@actions/core'\n\n/* equals to a call of os.platform() */\nplatform.platform // 'win32' | 'darwin' | 'linux' | 'freebsd' | 'openbsd' | 'android' | 'cygwin' | 'sunos'\n\n/* equals to a call of os.arch() */\nplatform.arch // 'x64' | 'arm' | 'arm64' | 'ia32' | 'mips' | 'mipsel' | 'ppc' | 'ppc64' | 'riscv64' | 's390' | 's390x'\n\n/* common shorthands for platform-specific logic */\nplatform.isWindows // true\nplatform.isMacOS // false\nplatform.isLinux // false\n\n/* run platform-specific script to get more details about the exact platform, works on Windows, MacOS and Linux */\nconst {\n  name, // Microsoft Windows 11 Enterprise\n  version, // 10.0.22621\n} = await platform.getDetails()\n```\n\n#### Populating job summary\n\nThese methods can be used to populate a [job summary](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary). A job summary is a buffer that can be added to throughout your job via `core.summary` methods.\n\nJob summaries when complete must be written to the summary buffer file via the `core.summary.write()` method.\n\nAll methods except `addRaw()` utilize the `addRaw()` method to append to the buffer, followed by an EOL using the `addEOL()` method.\n\n```typescript\n\n// Write raw text, optionally add an EOL after the content, defaults to false\ncore.summary.addRaw('Some content here :speech_balloon:', true)\n// Output: Some content here :speech_balloon:\\n\n\n// Add an operating system-specific end-of-line marker\ncore.summary.addEOL()\n// Output (POSIX): \\n\n// Output (Windows): \\r\\n\n\n// Add a codeblock with an optional language for syntax highlighting\ncore.summary.addCodeBlock('console.log(\\'hello world\\')', 'javascript')\n// Output: <pre lang=\"javascript\"><code>console.log('hello world')</code></pre>\n\n// Add a list, second parameter indicates if list is ordered, defaults to false\ncore.summary.addList(['item1','item2','item3'], true)\n// Output: <ol><li>item1</li><li>item2</li><li>item3</li></ol>\n\n// Add a collapsible HTML details element\ncore.summary.addDetails('Label', 'Some detail that will be collapsed')\n// Output: <details><summary>Label</summary>Some detail that will be collapsed</details>\n\n// Add an image, image options parameter is optional, you can supply one of or both width and height in pixels\ncore.summary.addImage('example.png', 'alt description of img', {width: '100', height: '100'})\n// Output: <img src=\"example.png\" alt=\"alt description of img\" width=\"100\" height=\"100\">\n\n// Add an HTML section heading element, optionally pass a level that translates to 'hX' ie. h2. Defaults to h1\ncore.summary.addHeading('My Heading', '2')\n// Output: <h2>My Heading</h2>\n\n// Add an HTML thematic break <hr>\ncore.summary.addSeparator()\n// Output: <hr>\n\n// Add an HTML line break <br>\ncore.summary.addBreak()\n// Output: <br>\n\n// Add an HTML blockquote with an optional citation\ncore.summary.addQuote('To be or not to be', 'Shakespeare')\n// Output: <blockquote cite=\"Shakespeare\">To be or not to be</blockquote>\n\n// Add an HTML anchor tag\ncore.summary.addLink('click here', 'https://github.com')\n// Output: <a href=\"https://github.com\">click here</a>\n\n```\n\nTables are added using the `addTable()` method, and an array of `SummaryTableRow`.\n\n```typescript\n\nexport type SummaryTableRow = (SummaryTableCell | string)[]\n\nexport interface SummaryTableCell {\n  /**\n   * Cell content\n   */\n  data: string\n  /**\n   * Render cell as header\n   * (optional) default: false\n   */\n  header?: boolean\n  /**\n   * Number of columns the cell extends\n   * (optional) default: '1'\n   */\n  colspan?: string\n  /**\n   * Number of rows the cell extends\n   * (optional) default: '1'\n   */\n  rowspan?: string\n}\n\n```\n\nFor example\n\n```typescript\n\nconst tableData = [\n  {data: 'Header1', header: true},\n  {data: 'Header2', header: true},\n  {data: 'Header3', header: true},\n  {data: 'MyData1'},\n  {data: 'MyData2'},\n  {data: 'MyData3'}\n]\n\n// Add an HTML table\ncore.summary.addTable([tableData])\n// Output: <table><tr><th>Header1</th><th>Header2</th><th>Header3</th></tr><tr></tr><td>MyData1</td><td>MyData2</td><td>MyData3</td></tr></table>\n\n```\n\nIn addition to job summary content, there are utility functions for interfacing with the buffer.\n\n```typescript\n\n// Empties the summary buffer AND wipes the summary file on disk\ncore.summary.clear()\n\n// Returns the current summary buffer as a string\ncore.summary.stringify()\n\n// If the summary buffer is empty\ncore.summary.isEmptyBuffer()\n\n// Resets the summary buffer without writing to the summary file on disk\ncore.summary.emptyBuffer()\n\n// Writes text in the buffer to the summary buffer file and empties the buffer, optionally overwriting all existing content in the summary file with buffer contents. Defaults to false.\ncore.summary.write({overwrite: true})\n```","publish_time":1769651706753,"_cnpm_publish_time":1769651706753,"dist-tags":{"latest":"3.0.1","preview":"1.6.0-beta.0"}}