I'm writing a JavaScript-based GitHub action (using https://docs.github.com/en/actions/creating-actions/creating-a-javascript-action) and now I want to checkout a repository using, for example, actions/checkout@v3. I already know how to do this in a YAML workflow (and I don't want to do it this way). How do I call it from the JavaScript?
Asked
Active
Viewed 88 times
-1
-
I might reword the title to reflect that you are specifically looking to do this from a node action, because now with composite actions you can easily call another action from a custom (composite) action. – CortexCompiler Jul 05 '23 at 16:21
2 Answers
0
The way I achieved this was by creating a composite
Action and then calling the node action located in the same repo. The code would look something like this:
name: 'Composite action with embedded node action'
description: 'Approach to using other actions with a node action'
author: 'cortexcompiler'
inputs:
input1:
required: false
description: 'Example of passing through an input'
runs:
using: "composite"
steps:
- name: Check out Git repository
uses: actions/checkout@v3
- name: Now Calling the Node action in directory ./actions/node-action
uses: ./actions/node-action
with:
input1: ${{ inputs.input1 }}
Directory structure:
├── action.yaml
├── actions
│ └── node-action
│ └── action.yaml

CortexCompiler
- 111
- 5
0
Well, ChatGPT to the rescue. It seems there's no way to directly call an action from the code of another action (e.g. in the JavaScript). But what you could do is create a repository_dispatch
action that calls the action you want and then to use an HTTP POST in your code to call your repository_dispatch
action. It's a messy workaround, but it seems to be the only way for now.

sffortytwo
- 127
- 1
- 7