Comments (15)
@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.
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.
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.
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.
Hi @adamhenson
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.
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.
Perhaps Github Actions could support downloading a zip archive of node_modules from Github releases for specific actions.
from hello-world-javascript-action.
@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.
@rachmari, @andymckay, @jorgebg, @thboop - do you have any thoughts about this issue?
from hello-world-javascript-action.
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.
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.
ncc
not work too.
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)
- .
- Rename default branch
- inputs.who-to-greet.required should be set to false since the parameter has a default value HOT 2
- Github Actions uses invalid environment variables. HOT 5
- JavaScript 01
- The `set-output` command is deprecated
- Absolute joke from a security perspective HOT 2
- hello-world-javascript-action
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hello-world-javascript-action.