Skip to main content
InterviewHubPRO
Section Overview
Q17

Question 17 of 50

Part 2: Advanced Workflows, Security & Containerization (Mid-Level)

34%
CI/CD & GitHub Actions (50 Qs)•Part 2: Advanced Workflows, Security & Containerization (Mid-Level)

How do you create Custom JavaScript / TypeScript Actions?

junior LevelCode ExampleState ManagementTypeScriptSecurity & Auth

In Simple Words: Custom actions allow encapsulating complex pipeline automation:

  1. Define metadata in action.yml (inputs, outputs, entrypoint).
  2. Write logic in TypeScript using @actions/core and @actions/github.
  3. Compile using @vercel/ncc to bundle all dependencies into a single dist/index.js file.
typescript
// src/index.ts
import * as core from '@actions/core';
import * as github from '@actions/github';

async function run() {
  try {
    const environment = core.getInput('environment', { required: true });
    core.info(`Deploying to environment: ${environment}`);
    
    // Set output variable for downstream steps
    core.setOutput('deployment_id', Date.now().toString());
  } catch (error: any) {
    core.setFailed(error.message);
  }
}
run();