Open github-learning-lab[bot] opened 3 years ago
We typically don't commit a node_modules
folder in a repository. These can often grow to be huge if your project has many dependencies. Because of the way Node works this folder is a necessary evil, but there is a way to get rid of it!
First you need to install a tool called ncc. You'll want to install this tool globally so that you can use as if it's any other CLI tool on your machine.
What ncc does is take all the dependencies within your project and compile them into a single JavaScript file. This allows you to avoid committing the node_modules
folder in your actions source code.
Install ncc
npm install -g @zeit/ncc
Using ncc When you use ncc:
ncc build <input-file>
A new directory named dist
will be created. Within that directory you will find a file named index.js
. To tell GitHub Actions that this new index.js
file is the one that should run when your action is used a small edit to the action.yml
file needs to be made.
before:
runs:
using: "node12"
main: "index.js"
after:
runs:
using: "node12"
main: "dist/index.js"
Once you make this change you can delete the node_modules
folder and commit those changes to the repository that contains your Actions source code.
📖Further help using ncc is in the GitHub Actions documentation.
Publishing your actions is a great way to help others in your team and across the GitHub community. Although actions do not need to be published to be consumed by adding them to the marketplace you make them easier to find.
Some notable actions you will find on the marketplace are:
And that just scratches the surface of the 1600+ and counting actions you will find on the marketplace 😄
📖Follow this guide to learn how to publish your actions to the GitHub Marketplace
It was so fun having you as a student while taking this course. I'll forever cherish our time together Anurenjini78
You can keep this repository forever to remember our time... I actually encourage you to do so! This has now become your central point for notes on writing JavaScript actions 😄
I really do think of everything!
Make sure to visit Learning Lab for more courses on GitHub Actions and other awesome tech content.
We would love to hear what you thought about this course, share your experience with us and others in the Community forum
To fully complete your course close this issue
Great job!
You did it 🎉
You have successfully written three different JavaScript actions.
Let's take a quick look at all the things you learned in this course:
Workflows Along the way you learned a little about workflows and how to configure them. You managed to accomplish all these things:
That's quite a bit for a course that doesn't cover workflows!
Action metadata
action.yml
fileinputs:
andoutputs:
allowed you to create more dynamic and reusable metadata files for your actions.JavaScript actions Wow, what a series of tasks! You started with the traditional
hello world
in the console, which was then expanded to use theinput:
parameters specified in the actions metadata. Through the use of that metadata you were able to be flexible with your greeting.You learned how GitHub Actions behave when consuming external APIs and you also used the response from an external API as an
output:
parameter for a later step in the workflow.Lastly you saw how to use actions to interact with a repository by creating an issue containing a joke.
You used multiple packages in your action source code, you consumed
inputs:
and setoutputs:
.You learned how to use the
@actions/core
package to write errors and terminate a misbehaving action.At this point you are armed with everything you need to know to go out there and begin creating your own custom JavaScript actions.
We aren't done yet 😉
Throughout this course I have promised to show you how to get rid of the
node_modules
folder in your repository.I also want to take a few minutes to point you to the information you need to place your own custom actions on the GitHub Marketplace for others to use.