Code Monkey home page Code Monkey logo

Comments (15)

adamhenson avatar adamhenson commented on May 23, 2024 7

@123aswin123 in your example you are consuming an action from a workflow which is not the same as creating an action. This project is an example of how to create a JavaScript GitHub Action. The problem this issue points out is the inability to create an action without including node_modules.

from hello-world-javascript-action.

adamhenson avatar adamhenson commented on May 23, 2024 4

Thanks @rachmari. Yes I tried NCC, but it threw an error in a certain project… so it seems unstable. Anyways, thanks for your responses. It’s not the end of the world… just inconvenient and not ideal especially as an open source project.

from hello-world-javascript-action.

irl-segfault avatar irl-segfault commented on May 23, 2024 2

bump, any way we can just have the actions runner npm install to save us all from checking in node_modules, and alternatively to avoid an extra manual npm install hack step?

from hello-world-javascript-action.

flagbird avatar flagbird commented on May 23, 2024 1

Probably it's a bad practice that the direct content of a repository is the action in such a case. One (not so elegant) solution could be to have one repo for the code that you'll work with and another repo where you deploy a build-result to, that's going to be the action you will use.

from hello-world-javascript-action.

rachmari avatar rachmari commented on May 23, 2024 1

Hi @adamhenson 👋. This repo is a companion to the documentation in this guide: https://docs.github.com/en/actions/creating-actions/creating-a-javascript-action#commit-tag-and-push-your-action-to-github

While checking in the node_modules directory is counterintuitive, here is a bit of documentation about why we require you to check in the node_modules directory when creating an action (from the guide 👆):

GitHub downloads each action run in a workflow during runtime and executes it as a complete package of code before you can use workflow commands like run to interact with the runner machine. This means you must include any package dependencies required to run the JavaScript code.

I've reached out to see if there are any plans to change that in the future. I'll drop a note here if I hear about any plans to change that going forward.

from hello-world-javascript-action.

rachmari avatar rachmari commented on May 23, 2024 1

If there is a better place to open this issue - please do let me know where.

@adamhenson finding an existing discussion or opening a new one here is the best place: https://github.com/github/feedback/discussions/categories/actions-and-packages-feedback

Appreciate the link to the docs but it’s still unclear why @irl-segfault’s suggestion isn’t possible.

The actions team doesn't currently have any plans to update the runners to be able to perform the npm install for each JavaScript action defined in a workflow. I suspect that could increase workflow time significantly in some cases as well, depending on how many actions you use in a single workflow.

Rather than checking in the entire directory of node_modules, another option that the guide refers to is using https://github.com/vercel/ncc to compile all of the node modules into a single file. I'm not sure if that's what you were referring to when you said: "or even the Vercel option which generates a gigantic diff" or not. GitHub uses ncc in most (if not all) of our first-party actions.

from hello-world-javascript-action.

borkdude avatar borkdude commented on May 23, 2024 1

Perhaps Github Actions could support downloading a zip archive of node_modules from Github releases for specific actions.

from hello-world-javascript-action.

IgnorantSapient avatar IgnorantSapient commented on May 23, 2024

@chenyong I agree with you 100%

However, here is a workaround if node_modules is in your gitignore and you wish to generate node_modules during runtime:

on: [push]

jobs:
  hello_world_job:
    runs-on: ubuntu-latest
    name: A job to say hello
    steps:
      # To use this repository's private action,
      # you must check out the repository
      - name: Checkout
        uses: actions/checkout@v2
      - name: Install Packages
        run: npm install
      - name: Hello world action step
        uses: ./ # Uses an action in the root directory
        id: hello
        with:
          who-to-greet: "Mona the Octocat!!!!!"
      # Use the output from the `hello` step
      - name: Get the output time
        run: echo "The time was ${{ steps.hello.outputs.time }}"

The above mentioned code is a remix of the code given here

from hello-world-javascript-action.

adamhenson avatar adamhenson commented on May 23, 2024

@rachmari, @andymckay, @jorgebg, @thboop - do you have any thoughts about this issue?

from hello-world-javascript-action.

adamhenson avatar adamhenson commented on May 23, 2024

Thanks @rachmari. If there is a better place to open this issue - please do let me know where. Appreciate the link to the docs but it’s still unclear why @irl-segfault’s suggestion isn’t possible. This issue is impactful in the open source sense in that PRs are quite difficult to manage with the diff from node_modules or even the Vercel option which generates a gigantic diff (and threw errors for me).

from hello-world-javascript-action.

AraHaan avatar AraHaan commented on May 23, 2024

I wish that github native dependabot could update the node_modules folder for us every time it also updates our package.json and package.lock.json.

from hello-world-javascript-action.

CarsonSlovoka avatar CarsonSlovoka commented on May 23, 2024

ncc not work too.


https://docs.github.com/en/actions/creating-actions/creating-a-javascript-action#commit-tag-and-push-your-action-to-github

They tell you

use a tool called @vercel/ncc to compile your code and modules into one file used for distribution.

and step 4:

If you already checked in your node_modules directory, remove it. rm -rf node_modules/*

when I remove node_modules/* I will get

Error: Cannot find module '@actions/core'

from hello-world-javascript-action.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.