Coder Social home page Coder Social logo

skills-write-javascript-actions's Introduction

Write JavaScript Actions

Write your own GitHub JavaScript Action and automate customized tasks unique to your workflow.

Step 1: Initialize a new JavaScript project

Welcome to the course 🎉

Configuring a workflow

Actions are enabled on your repository by default, but we still have to tell our repository to use them. We do this by creating a workflow file in our repository.

A workflow file can be thought of as the recipe for automating a task. They house the start to finish instructions, in the form of jobs and steps, for what should happen based on specific triggers.

Your repository can contain multiple workflow files that carry out a wide variety of tasks. It is important to consider this when deciding on a name for your workflow. The name you choose should reflect the tasks being performed.

In our case, we will use this one workflow file for many things, which leads us to break this convention for teaching purposes.

Read more about workflows

On to your development environment

Our JavaScript actions are going to leverage the GitHub ToolKit for developing GitHub Actions.

This is an external library that we will install using npm which means that you will need Node.js installed.

We find writing actions to be easier from a local environment vs trying to do everything right here in the repository. Doing these steps locally allows you to use the editor of your choice so that you have all the extensions and snippets you are used to when writing code.

If you do not have a preferred environment then we suggest following along exactly as you see on the screen, which means you'll need to install Visual Studio Code.

Don't forget to set up your workstation

Most of your work going forward will take place away from your Skills repository, so before continuing with the course ensure you have the following installed on your local machine.

  1. Node.js
  2. Visual Studio Code or your editor of choice
  3. Git

⌨️ Activity 1: Initialize a new JavaScript project

Once you have the necessary tools installed locally, follow these steps to begin creating your first action.

  1. Open the Terminal (Mac and Linux) or Command Prompt (Windows) on your local machine
  2. Clone your Skills repo to your local machine:
    git clone <this repository URL>.git
  3. Navigate to the folder you just cloned:
    cd <local folder with cloned repo>
  4. We are using branch called main.
    git switch main
  5. Create a new folder for our actions files:
    mkdir -p .github/actions/joke-action
  6. Navigate to the joke-action folder you just created:
    cd .github/actions/joke-action
  7. Initialize a new project:
    npm init -y
  8. Install the request, request-promise and @actions/core dependencies using npm from the [GitHub ToolKit] (https://github.com/actions/toolkit):
    npm install --save request request-promise @actions/core
  9. Commit those newly added files,we will remove the need to upload node_modules in a later step:
    git add .
    git commit -m 'add project dependencies'
  10. Push your changes to your repository:
    git push
  11. Wait about 20 seconds then refresh this page (the one you're following instructions from). GitHub Actions will automatically update to the next step.

Get help: Post in our discussion boardReview the GitHub status page

© 2023 GitHub • Code of ConductMIT License

skills-write-javascript-actions's People

Contributors

kacper2k1lop avatar github-actions[bot] avatar

Watchers

 avatar

skills-write-javascript-actions's Issues

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.