@actions/core toolkit to inspect annotations, logs, summaries, and properly handle failures. By the end, you’ll be able to:
- Read inputs and set outputs
- Log at different levels (info, notice, warning, error)
- Mask secrets and export environment variables
- Generate job summaries
- Fail actions with descriptive exit codes
Table of Contents
- Importing and Cloning the Repository
- Reviewing action.yaml
- Examining package.json
- Business Logic in index.js
- Building the Action
- Testing with a Workflow
- Enabling Actions and Running the Workflow
7.1 Viewing Annotations
7.2 Inspecting Logs - Error Scenario: Invalid Phone Number
- Setting Failure Exit Codes
- Conclusion
- Links & References
1. Importing and Cloning the Repository
First, import the sample project into your GitHub account. Choose TroubleshootingJS-Actions, set visibility to Public, and click Import.
2. Reviewing action.yaml
Open action.yaml, the manifest that defines inputs, outputs, and runtime:3. Examining package.json
The package.json file lists dependencies for your action bundle:- @actions/core: Toolkit for inputs, outputs, logging, secret masking
- @vercel/ncc: Bundles your JavaScript into a single file

4. Business Logic in index.js
The main script reads inputs, logs messages, masks secrets, exports variables, and builds a summary:The
core.setSecret() method masks sensitive values in logs. Use it whenever you log or store secrets.5. Building the Action
Install dependencies and bundle intodist/index.js:
dist/index.js with all required modules included.
6. Testing with a Workflow
Create.github/workflows/test.yml to trigger the action manually:
7. Enabling Actions and Running the Workflow
Imported repositories have Actions disabled by default. Enable them before running:- Go to Settings → Actions → General
- Under Actions permissions, select Allow all actions and reusable workflows


core.error() logs an error but does not fail the step. To stop the job on error, use core.setFailed().7.1 Viewing Annotations
GitHub UI displays annotations from different logging levels:
7.2 Inspecting Logs
Detailed logs show messages and confirm that secrets are masked:
8. Error Scenario: Invalid Phone Number
If the phone number is shorter than 10 digits, you’ll see the logged error but the job remains green (until you opt to fail it):
9. Setting Failure Exit Codes
To mark the step as failed and stop downstream jobs, uncommentcore.setFailed():


10. Conclusion
You’ve covered essential patterns for debugging JavaScript Actions:- Use
@actions/corefor inputs, outputs, logs, secrets, and summaries - Bundle with ncc for single-file distribution
- Write workflows to validate functionality
- View annotations and logs directly in the GitHub UI
- Fail actions properly with
core.setFailed()
11. Links & References
- GitHub Actions Toolkit – core
- GitHub Actions Exit Codes
- ncc Bundler by Vercel
- GitHub Workflow Syntax
- Node.js v20