Giter Site home page Giter Site logo

nejilabs / colbyfayock-cgaingajt-20210205 Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 159 KB

🧩 Colby Fayock - Custom GitHub Actions in Node.js - GitHub Actions JavaScript Tutorial (Feb 5, 2021) | Link: https://www.youtube.com/watch?v=Ef0gPGUh9oo&ab_channel=ColbyFayock | Article of this Course: https://spacejelly.dev/posts/how-to-create-a-custom-github-action-with-node-javascript/

Home Page: https://www.youtube.com/watch?v=Ef0gPGUh9oo&ab_channel=ColbyFayock

JavaScript 100.00%
devops github github-actions github-actions-toolkit javascript nodejs octokit github-api github-core google-cloud

colbyfayock-cgaingajt-20210205's Introduction

colbyfayock-cgaingajt-20210205's People

Contributors

njtalba5127 avatar

Watchers

 avatar

Forkers

njtalba5127

colbyfayock-cgaingajt-20210205's Issues

1426 - Create a Token

my notes are still in issue #20 , the course is just idk if were just going for speed and ongoing like this. things will just mix up. anyways we should create proper notes for these projects

109 - Create a New Repository

We did it our way 💩

What they did in the course

  • Create New Git Repository
  • Put Git Repository up to Github
  • Clone the Git Repository from Github to our Local Machine

What we did

  • Create new project folder on our local comp
  • Initialise the project folder as a git repository
  • Put it up to Github

0 - Introduction

Notes

  • In this course we will learn how to make a custom github action with javascript and node.js
  • Github actions are an awesome feature from github that allows you to automate your code, tasks, and workflows like ci / cd processes right inside our repository.
  • Github already has a huge marketplace with actions that are ready to plug into your projects ex:
    • talking with jira
    • changes status of an issue
    • scan project for security issues
  • But as big as this marketplace is, sometimes you just need something that is custom whether if its for a specific infrastructure, or its just not quite doing what you need it to do.
  • So instead, github lets you create your own custom actions, similar to what you might do if you’re publishing a npm package, where we can create our workflow, and then anybody can use it from right inside of the repository.
  • So once again in this course, were going to learn how to create a github action using javascript and node.js, particularly, were going to recreate this thank you action demo that they created where anytime someone opens a new pull request, we will automatically run a script that will say thank you to the person who created it as well as its gonna post a gif from tenor api onto that pull request.

109 - Create a New Repository

ok no this was just a test.

this issue was created from a documentations issue i made for this project with the contents of the course as a todo seen in the documentations issue. I just tested how it worked and it made this new issue with an indicator it being tracked by #12 .

After finding this out, I guess I'll have an easier time making new issues then cool!

Transferred Documentations from Issue #2

We did it our way 💩

What they did in the course

  • Create New Git Repository
  • Put Git Repository up to Github
  • Clone the Git Repository from Github to our Local Machine

What we did

  • Create new project folder on our local comp
  • Initialise the project folder as a git repository
  • Put it up to Github

606 - Create a New Directory

umm ok screw the notes we can do the notes after, if we want to get more shez done, we can just summarise what we did and then just look back into the course for more info. afterall, were finding a way to better the way we do our projects so that well be more efficient and therefore productive 💩

anyways ill just summarise whatever things done while following the course as a todo task points.

  • create a new directory called ".github" at the root of the repo
  • create another directory inside that .github directory called "workflows"
  • create a new yaml file called "test.yml" inside the workflows directory

test.yml:

name: Test

on:
  pull_request:
    types: [opened]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: ./

Conclusion

in this course, tho there were a lot of things we got obstracted with such as bumping into the updated tenor api problem, and need of code fixings and debugging. we still went through and able to deliver with the supposed final product (tho im not sure about the randomising gif).

we ultimately learned and experienced working with github actions, their core tool kit and octokit, as well as an api. and building ultimately this action out of nodejs.

obviously there are more things to learn about github actions since we only learned how to comment on a new pr, and more stuff to explore with tenor api but its pretty easy.

overall, we would need more projects or we could explore on our own with regards to the things we can do with github actions.

for the course, its a good course made by a cool guy, tho its made a year ago and we did bumped with version incompatibility (especially tenor api version), you can still work with it as the fundamentals and explanations of how things worked were pretty clear, and that we just made a simple github action out of it.

overall its a good project that we successfully followed through. ayts thats all

722 - Add a README

  • using github web, create a new readme.md (we will be doing that on our develop branch of course which they wont do in the course, cuz thats our way of doing things), however, before committing, select the option "create a new branch for this commit and start a pull request"

305 - Input Two Configuration Options

  • input two configuration options in our action.yml

for our github action, we also want to input two configuration options so that we can allow people to actually use their instances and api tokens for this action.

so in our action.yml, they pasted this inputs object which contains the GITHUB_TOKEN that we will use for our action to be allowed to actually add the 'Thank you' comment to every new pull request in Github, as well as the TENOR_TOKEN which allows the action to reach out to the tenor api.

what they did:

inputs:
  GITHUB_TOKEN:
    description: "Github token"
    required: true
  TENOR_TOKEN:
    description: "Tenor API token"
    required: true
  • set up our environment

we need to set up our environment. so we're gonna use the runs object and pass in "using: node12" which were going to tell them that we want to use the environment of node12, and then "main" which were going to specify as "dist/index.js" which is going to be the ultimate path of our action script that we want to run.

what they did:

runs:
  using: "node12"
  main: "dist/index.js"

now in order for our action to actually run, we need to create a script.

  • create a new directory called "src" at the root of our project repository
  • create a new js file called "action.js"

what they did inside src/action.js:

async function run() {
  console.log('Hello, world!');
}

run();

the reason why we are creating an async function and running it is so that we can use the async await syntax within this block. but for now we are gonna leave this console.log just so that we can test that it's working.

we can even test that out by going over back to our terminal then:

node src/action.js

that should log "Hello, world!" on our terminal.

now in order to run this action script, we saw that we can do that right from the terminal. but inside of our action.yml file, we described that our main entry point as "dist/index.js". thats because we are gonna compile it from our src directory into that dist folder. to do that were gonna use a tool called "ncc" from vercel
that will allow us to compile our project into a single file. this will be particularly helpful when we want to take dependencies and make them all runnable from one single file.

so to start, inside your terminal, run yarn add @vercel/ncc which will be add the dependency to our project, while generating our yarn.lock file. you can also use npm install to install the dependency which will make the package-lock.json, either works but what they used in the course we follow hehe.

  • add/install vercel's ncc to the project as a dependency

next we're going to add a new script "build": "ncc build src/action.js -o dist" inside our package.json. this is how our package.json should somewhat look like, with the newly added script:

{
  "name": "colbyfayock-cgaingajt-20210205",
  "version": "1.0.0",
  "description": "🧩 Colby Fayock - Custom GitHub Actions in Node.js - GitHub Actions JavaScript Tutorial (February 5, 2021) | Link: https://www.youtube.com/watch?v=Ef0gPGUh9oo&ab_channel=ColbyFayock",
  "main": "index.js",
  "scripts": {
    "build": "ncc build src/action.js -o dist",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/newojima/colbyfayock-cgaingajt-20210205.git"
  },
  "author": "nellyXinwei",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/newojima/colbyfayock-cgaingajt-20210205/issues"
  },
  "homepage": "https://github.com/newojima/colbyfayock-cgaingajt-20210205#readme",
  "dependencies": {
    "@vercel/ncc": "^0.34.0"
  }
}

shet this comment is really long, i think its really better to take documentation notes in our vscode / notion instead of being here but whatever, were just trying anyways right.

  • add a new script "build": "ncc build src/action.js -o dist" in our package.json
  • run on terminal yarn build (or npm run build if you used npm instead of yarn to build our dist with our compiled index.js file.

similarly, we can see that itll also log "Hello, world!" when we do on terminal node dist/index.js.

umm ok this is not in the course but i made a new ".gitignore" file in our root of our project repository then added "node_modules" in it so that it doesnt include the node_modules in our commit to github.

  • create new ".gitignore" file at the root of our project repository
  • add "node_modules" inside the ".gitignore" file

0 - Introduction

Notes

  • In this course we will learn how to make a custom github action with javascript and node.js
  • Github actions are an awesome feature from github that allows you to automate your code, tasks, and workflows like ci / cd processes right inside our repository.
  • Github already has a huge marketplace with actions that are ready to plug into your projects ex:
    • talking with jira
    • changes status of an issue
    • scan project for security issues
  • But as big as this marketplace is, sometimes you just need something that is custom whether if its for a specific infrastructure, or its just not quite doing what you need it to do.
  • So instead, github lets you create your own custom actions, similar to what you might do if you’re publishing a npm package, where we can create our workflow, and then anybody can use it from right inside of the repository.
  • So once again in this course, were going to learn how to create a github action using javascript and node.js, particularly, were going to recreate this thank you action demo that they created where anytime someone opens a new pull request, we will automatically run a script that will say thank you to the person who created it as well as its gonna post a gif from tenor api onto that pull request.

234 - Register Our Package With Github

  • create action.yml

to register our package with Github, we need to create a new file called "action.yml" at the root of our project repository.

  • configure our action for Github to read

inside the action.yml file, were going to configure our action for Github to read, adding things like the name of the action, entry points and environments so that Github knows how to run our application.

this is what they did in the course:

name: 'Thank You Action'
description: 'Say "Thank You" to new pull requests'
author: 'Colby Fayock'

we'll do it our way:

name: 'colbyfayock-cgaingajt-2021020'
description: 'Say "Thank You" to new pull requests'
author: 'nellyXinwei'

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.