←  github actions

Views:

Executing javascript code in github action

We can execute javascript code in our github action with the help of github-script. Let's try this with a Hello World example-

name: Hello World in JS

on: [push, pull_request]

jobs:
  say-hello-world:
    runs-on: ubuntu-latest
    steps:
      - name: Say `Hello World` from JS
        uses: actions/github-script@v6
        with:
          script: |
            console.log('Hello World');
            console.log('Hello Again...')

Result

Following is the output for the above github action-

hello-world-in-js-result