KakaoWebtoon Refactors Complex GitHub Actions Shell Scripts into JavaScript Actions
Key point
Improved readability by converting multi-environment conditional statements into a Map structure and enhanced execution performance with node_modules caching.
Details
The KakaoWebtoon frontend team refactored GitHub Actions Composite actions, which had become complex due to service expansion, into JavaScript actions. The existing shell scripts suffered from poor readability and difficult maintenance due to multiple conditional statements based on 5 environments (env) and 4 regions.
Simplifying Conditional Statements Using Map Structure
Complex nested if-else conditional statements were converted into Map objects to simplify the code. Using object structures like ENV_REGION_MAP allows direct reference to required values in the form of ENV_REGION_MAP[env][region], solving the issue of deepening conditional statement depth and improving readability.
JavaScript Action Implementation and Dependency Management
Logic to receive input values and set output values was implemented using the @actions/core package. To resolve the Cannot find module error that occurs when executing JavaScript actions, the workflow was configured to install and cache dependencies at runtime using actions/setup-node and actions/cache, without committing node_modules to the repository. This reduced the storage burden on the repository while maintaining execution performance.
Accessing Event Information and Tool Improvements
Using the @actions/github package allows access to event context such as repository information, failure location, and triggering user when a workflow is triggered. Additionally, the GitHub Actions extension for VS Code was released in public beta, enabling users to check workflow execution status without a browser.
This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.
Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.