Day-20 | GitHub Actions | Actions vs Jenkins | 3 Projects with examples | Configure your own runner

Abhishek.Veeramalla
2 Feb 202322:18

Summary

TLDRIn this 20th installment of the complete DevOps course, Abhishek introduces GitHub Actions as a CI/CD solution, comparing it with Jenkins and emphasizing its focus on the GitHub platform. He demonstrates setting up a basic Python project with GitHub Actions, showcasing its simplicity and the use of YAML for configuration. Advantages like ease of use, no maintenance overhead, and cost-effectiveness for public projects are highlighted, alongside the limitation of platform specificity. The tutorial includes step-by-step examples and encourages viewers to try GitHub Actions for themselves.

Takeaways

  • 📚 The video is part of a complete DevOps course, focusing on day 20 discussing GitHub Actions as a CI/CD solution.
  • 🔧 The speaker previously covered Jenkins in detail, including installation, configuration, and live projects, emphasizing the use of Docker to optimize compute resources.
  • 📝 GitHub Actions is highlighted as a CI/CD solution that is specifically tailored for GitHub, similar to how GitLab CI is for GitLab.
  • 🤔 The choice between GitHub Actions and Jenkins should be based on the organization's platform strategy and potential future migrations.
  • 🛠️ GitHub Actions eliminates the need for plugin installations, as it uses a marketplace of pre-installed plugins, simplifying the setup process.
  • 📁 The script explains the basic structure of a GitHub Actions workflow file, starting with a '.github/workflows' directory and YAML configuration.
  • 🔄 The video demonstrates creating a simple Python addition program and its corresponding GitHub Actions workflow for testing the program.
  • 🔑 GitHub Actions provides native support for storing secrets, which is crucial for securing sensitive information like config files and tokens.
  • ⚙️ The script compares GitHub Actions with Jenkins, noting that GitHub Actions requires less maintenance and has a simpler user interface.
  • 💰 GitHub Actions offers free execution minutes for public projects, which can be a significant cost advantage over self-hosted solutions like Jenkins.
  • 🔄 The video concludes by recommending GitHub Actions for open-source projects staying within the GitHub ecosystem and not planning to migrate to other platforms.

Q & A

  • What is the main focus of the video script?

    -The main focus of the video script is to introduce and explain GitHub Actions as a CI/CD solution, comparing it with Jenkins and providing examples of how to use it for different tasks such as deploying to Kubernetes, Docker, and building Java applications with Maven and Sonar.

  • What is the significance of the 'dot GitHub workflows' folder in GitHub Actions?

    -The 'dot GitHub workflows' folder is significant because it is where all the GitHub Actions workflow files are stored. GitHub automatically looks for this folder to execute the defined pipelines when certain events, like a push or pull request, occur in the repository.

  • How does GitHub Actions handle the execution of multiple pipelines?

    -GitHub Actions can handle the execution of multiple pipelines by allowing the creation of multiple workflow files within the 'dot GitHub workflows' folder. Each file represents a separate pipeline that can be triggered by different events or conditions.

  • What is the advantage of using Docker containers as agents in Jenkins, as mentioned in the script?

    -Using Docker containers as agents in Jenkins is advantageous because it allows for more efficient use of compute resources. Containers can be spun up for specific tasks and then terminated once the job is done, preventing waste compared to using virtual machines as agents.

  • What is the primary difference between GitHub Actions and Jenkins in terms of platform focus?

    -The primary difference is that GitHub Actions is focused only on the GitHub platform, executing pipelines within the context of GitHub repositories. In contrast, Jenkins is a more general CI/CD tool that is not platform-specific.

  • Why might an organization choose not to use GitHub Actions or GitLab CI?

    -An organization might choose not to use GitHub Actions or GitLab CI if they anticipate migrating to a different platform in the future, as these tools are platform-oriented solutions. Moving from one platform to another would require significant effort to migrate the CI/CD configurations.

  • What is the purpose of the 'on' keyword in a GitHub Actions workflow file?

    -The 'on' keyword in a GitHub Actions workflow file specifies the events that will trigger the execution of the pipeline. It could be set to trigger on events like 'push', 'pull_request', or 'issues'.

  • How does the script describe the process of writing a basic GitHub Actions workflow for a Python application?

    -The script describes the process by first creating a Python file with a simple addition function and tests. Then, it outlines writing a workflow file that sets up a Python environment, checks out the code, installs dependencies, and runs the tests using pre-configured plugins available in GitHub Actions.

  • What are some of the plugins provided by GitHub Actions for different programming languages?

    -GitHub Actions provides plugins for various programming languages like 'setup-python' for Python, 'setup-java' for Java, and similar plugins for other languages, which help in setting up the required environment for executing the workflows.

  • How does GitHub Actions handle the storage of sensitive information like passwords or tokens?

    -GitHub Actions handles the storage of sensitive information through its native support for secrets. Users can store secrets in the repository settings, and these secrets can be accessed securely within the workflow files.

  • What are some of the advantages of using GitHub Actions over Jenkins mentioned in the script?

    -Some advantages include no need for hosting or maintenance effort, a simple user interface for writing pipelines, and cost-effectiveness, especially for public projects which can use GitHub Actions for free up to a certain limit of execution minutes.

Outlines

00:00

📚 Introduction to GitHub Actions in DevOps Course

In the 20th day of the complete DevOps course, Abhishek introduces GitHub Actions as a CI/CD solution, comparing it with Jenkins and emphasizing the importance of aligning the choice of CI/CD tool with organizational goals. He mentions the repository with step-by-step examples and clarifies that GitHub Actions is platform-oriented, best suited for those committed to GitHub. The video also touches on the efficiency of using Docker containers with Jenkins to save compute resources.

05:01

🛠️ GitHub Actions Workflow and File Structure

This section delves into the mechanics of GitHub Actions, explaining how to set up the workflow files within the '.github/workflows' directory of a repository. It discusses the flexibility of having multiple action files and the process of executing pipelines based on events like push or pull requests. Abhishek illustrates this with examples from the Argo CD project, highlighting different types of pipelines for various checks and processes.

10:02

🔧 Writing and Executing a Basic GitHub Actions Pipeline

Abhishek demonstrates how to write a GitHub Actions pipeline for a simple Python addition program. He guides through the process of setting up the environment, checking out the code, and running tests, all within the GitHub Actions framework. The explanation includes the use of YAML formatting, referencing the GitHub Actions documentation for plugin usage, and executing the pipeline with a test commit.

15:02

📝 Understanding GitHub Actions Syntax and Plugins

The script explains the syntax and structure of GitHub Actions files, highlighting the use of YAML and the similarity in configuration across different applications. It emphasizes the ease of writing pipelines with pre-installed plugins, comparing the process with Jenkins and pointing out the limitations of GitHub Actions plugins. The paragraph also covers the steps involved in setting up a Python environment and running tests within a GitHub Actions pipeline.

20:03

🔑 Storing Secrets and Advanced GitHub Actions Configuration

This part of the script discusses the security aspect of storing sensitive information like config files and tokens in GitHub Actions. It shows how to use GitHub's native support for secrets and how to configure custom runners for more specific needs. The comparison with Jenkins continues, focusing on the ease of setup and the reduced maintenance overhead of GitHub Actions.

🤔 Comparing GitHub Actions and Jenkins: Pros and Cons

In the conclusion, Abhishek compares GitHub Actions with Jenkins, outlining the pros and cons of each. He points out the advantages of GitHub Actions for public projects on GitHub, the ease of use, and the reduced maintenance. However, he also mentions the limitations, especially regarding portability and the scope of available plugins. The summary advises on choosing the right tool based on project needs and platform commitment.

Mindmap

Keywords

💡DevOps

DevOps is a set of practices intended to reduce the time between committing a change to a repository and the change being placed into production. In the video, the speaker is teaching a complete DevOps course, which includes various tools and practices like GitHub Actions and Jenkins, to streamline the software development and deployment process.

💡GitHub Actions

GitHub Actions is an automation tool integrated within GitHub that allows users to automate their software development workflows. The video focuses on GitHub Actions as a CI/CD (Continuous Integration/Continuous Deployment) solution, emphasizing its ease of use and integration with the GitHub platform.

💡Jenkins

Jenkins is an open-source automation server that facilitates the automation of all sorts of tasks associated with building, testing, and deploying software. The script contrasts Jenkins with GitHub Actions, discussing their use cases and comparing their features, such as the need for managing plugins and the ease of setup.

💡CI/CD

CI/CD stands for Continuous Integration/Continuous Deployment, which are practices in software development designed to improve the process of integrating changes from multiple contributors into a single software project. The video discusses how GitHub Actions and Jenkins serve as tools for implementing CI/CD practices.

💡Docker

Docker is a platform that uses containerization technology to make it easier to develop, ship, and run applications. In the script, Docker is mentioned as a way to use as an agent in Jenkins, allowing for efficient resource use by creating containers for pipeline execution that can be terminated after use.

💡Repository

A repository in the context of the video refers to a location where all the files for a project or software product are stored. The speaker mentions creating a repository for the course, which includes examples and step-by-step explanations of the topics covered, including GitHub Actions.

💡YAML

YAML is a human-readable data serialization standard used in programming languages and software applications. The video explains that GitHub Actions uses YAML formatting for its configuration files, which makes it easy for those familiar with YAML, such as in Kubernetes, to write GitHub Actions.

💡Workflows

In GitHub Actions, a workflow is a way to automate tasks within a repository. The script describes creating a 'workflows' directory in the '.github' folder of a repository to define the steps that GitHub Actions should execute when certain conditions are met, such as a push to the repository.

💡Self-hosted Runners

Self-hosted Runners in GitHub Actions are custom runners that you can host on your own infrastructure. The video mentions the option to configure custom Runners if the default runners provided by GitHub do not meet specific needs, such as when more compute resources are required for tasks like load testing.

💡Secrets

Secrets in the context of GitHub Actions are sensitive information that you store in your repository to be used by your workflows. The script explains that GitHub Actions provides native support for storing secrets, such as configuration files or tokens, ensuring they are kept secure and not exposed.

💡Plugins

Plugins in the video refer to the add-on tools provided by GitHub Actions to extend its functionality. The speaker explains that GitHub Actions has a marketplace of plugins that are automatically installed and can be easily used in workflows, simplifying the process compared to managing plugins in Jenkins.

Highlights

Introduction to GitHub Actions as a CI/CD solution on day 20 of the complete DevOps course.

Comparison of GitHub Actions with Jenkins, emphasizing GitHub Actions' focus on the GitHub platform.

Explanation of the benefits of using Docker as an agent in Jenkins to save compute resources.

GitHub Actions' ease of use with no need for plugin installation, unlike Jenkins.

Demonstration of creating a GitHub Actions workflow for a Python addition program.

Showcasing the simplicity of writing GitHub Actions using YAML formatting.

Discussion on the flexibility of GitHub Actions to run multiple pipelines for different tasks.

Introduction to the GitHub Actions Marketplace for plugins and how they simplify the CI/CD process.

Explanation of how to use GitHub Actions for various programming languages by changing plugins.

Guide on storing secrets in GitHub Actions for secure handling of sensitive information.

Comparison of the cost-effectiveness and maintenance overhead between GitHub Actions and Jenkins.

Advantages of GitHub Actions for open-source projects due to free execution minutes.

The potential downside of GitHub Actions being platform-specific and the implications for future platform migrations.

GitHub Actions' native support for storing CI/CD secrets, enhancing security.

How to set up self-hosted runners in GitHub Actions for customized execution environments.

Recommendation to use GitHub Actions for projects staying within the GitHub platform and open-source projects.

Invitation for feedback and engagement from viewers in the comment section.

Transcripts

play00:02

hello everyone my name is Abhishek and

play00:04

welcome back to my channel so today we

play00:06

are at day 20 of our complete devops

play00:08

course and in this video I am going to

play00:11

talk about GitHub actions so if you

play00:13

haven't watched our previous videos so

play00:15

in the last class we talked about

play00:16

Jenkins so we typically looked at

play00:19

Jenkins Zero to Hero where we talked

play00:21

right from installation of Jenkins to

play00:23

configuring it then you know we also

play00:26

looked at three live projects on Jenkins

play00:28

we saw how to use Docker as an agent

play00:31

like you know if you use a virtual

play00:32

machines as agent you are wasting a lot

play00:34

of compute resources on Jenkins so I

play00:36

explained you how to use Docker

play00:38

container so that your pipelines gets

play00:40

executed on this Docker agents and once

play00:42

your job is completed or once your job

play00:44

is done this containers gets deleted or

play00:47

you know this container gets terminated

play00:49

or killed so that there is no waste of

play00:51

computer right so if you haven't watched

play00:53

that video you can click on this link or

play00:56

you know you can look look into this

play00:57

repository or else you can also go to my

play01:00

channel and watch those videos perfect

play01:03

so today's topic is completely about

play01:05

GitHub actions

play01:07

so as usual I've created a repository

play01:09

for you in case somebody is not able to

play01:11

follow the video or let's say somebody

play01:13

feels that I'm going uh very fast or in

play01:16

the video what you can do is you can

play01:18

either watch this repository for this

play01:20

repository or start this repository and

play01:22

I have step by step step by step

play01:24

explanation of what I am going to talk

play01:26

today okay so now just a disclaimer this

play01:29

repository is not complete I'm going to

play01:30

add more and more things to this

play01:32

repository for now in the examples

play01:34

folder I just have three three examples

play01:36

one is deploy to kubernetes deploy to

play01:38

Docker spam and uh deploy one Java

play01:41

application by building it through Maven

play01:43

testing the code quality using Sonar and

play01:46

then deploying to kubernetes but in

play01:48

future I'll add more examples to it or

play01:50

even if you want to contribute to me uh

play01:52

to my GitHub repository you can also do

play01:54

that okay so now quickly jump on to the

play01:57

topic for today that is GitHub actions

play02:00

so what is GitHub actions so GitHub

play02:03

actions is yet another cicd solution

play02:05

okay so if you want to compare it with

play02:07

Jenkins they do similar tasks like you

play02:10

know they uh execute your continuous

play02:12

integration and continuous delivery but

play02:14

the primary difference is GitHub actions

play02:16

is focused only on GitHub okay just like

play02:19

gitlab Ci gitlab CI is also a CI CD

play02:23

solution that gitlab is offering you but

play02:25

it is only focused on gitlab platform so

play02:27

one big thing to understand or you know

play02:30

whenever you want to consider GitHub

play02:31

actions or gitlab CI the primary thing

play02:34

you have to understand is what your

play02:37

organization's goal is so do you want to

play02:39

continue on GitHub do you want to

play02:41

continue on gitlab or in the future you

play02:43

might want to migrate to different

play02:45

Platforms in such cases GitHub actions

play02:47

or gitlab CI is not the right solution

play02:49

for you okay because again they are

play02:52

platform oriented Solutions just like

play02:54

why we choose terraform over cloud

play02:56

formation templates because terraform is

play02:58

a tool that can work on multi-cloud or

play03:00

it can work on the hybrid Cloud

play03:02

environments so similarly GitHub actions

play03:05

although it is very powerful although it

play03:07

is like you know the tool that I am

play03:09

suggesting better than Jenkins uh like

play03:11

I'm going to explain you the pros and

play03:13

cons uh even in the first class of cicd

play03:15

I explained you why GitHub actions is

play03:17

better than Jenkins but saying that if

play03:20

you are platform or if your application

play03:22

is going to move from GitHub to gitlab

play03:25

in the future or GitHub to AWS in the

play03:27

future or any self-hosted git

play03:28

repositories or Azure devops do not use

play03:31

GitHub accents because you will waste a

play03:33

lot of time and then in future you will

play03:35

put lot of efforts from I mean in

play03:37

migrating your actions files to Jenkins

play03:39

files or something else

play03:41

okay perfect now

play03:43

so GitHub actions basically you don't

play03:46

have to install the plugins like for

play03:48

example uh if I want to write uh one

play03:51

GitHub actions file like my first GitHub

play03:53

actions file what you need to do is you

play03:56

just need to go to the root of your

play03:58

repository like you know the uh Parent

play04:01

Directory of your repository and just

play04:03

create dot actions sorry dot GitHub

play04:06

slash workflows folder okay so once you

play04:09

create dot GitHub workflows folder

play04:11

whatever action like you know let's say

play04:13

uh this is my GitHub actions file and in

play04:16

the first line I said on push okay so

play04:20

this will say GitHub that okay whenever

play04:22

there is a push action or whenever there

play04:24

is a commit that is created into this

play04:26

Repository

play04:27

by default you have to execute this

play04:29

pipeline okay whatever I write in this

play04:31

pipeline irrespective of what action is

play04:33

done like you know it can be a small

play04:35

commit it can be a big commit or you

play04:37

know you're you're modifying test

play04:39

related files you are modifying like

play04:40

irrespective of that once you define

play04:42

that on push action or on pull request

play04:46

action on issue action so what GitHub

play04:48

will do is it will look into the action

play04:50

like somebody has done a commit then it

play04:52

will come here and watch for the CI

play04:54

files and it understood okay there is a

play04:56

push uh request like whenever there is a

play04:58

push request the user has said that I

play05:01

need to execute this pipeline or actions

play05:03

file so GitHub will start executing the

play05:06

action file now is there a restriction

play05:08

like do I have to put only one action

play05:10

files here or I can put 10 action files

play05:12

for 10 20 action files so there is no

play05:15

limitation at all like you know

play05:17

depending upon the number of action

play05:18

files that you want to run for example

play05:20

uh uh in one action file you you might

play05:23

want to verify if a user has provided

play05:26

all the details in the pull request or

play05:27

not for example organizations have a

play05:30

like you know conditions like whenever

play05:32

you are creating a pull request you have

play05:34

to provide proper description you have

play05:36

to provide uh which issue is it solving

play05:38

so you can also validate those things in

play05:40

one actions file or in one pipeline in

play05:43

the other pipeline you can verify if

play05:45

there is formatting or linking issues in

play05:47

the third pipeline you can verify if

play05:48

your CI is passing in the fourth

play05:50

pipeline you can do your CD so it

play05:52

depends on how do you want to do for

play05:54

example let me show you one popular

play05:56

project uh let me show you uh Argo CD

play06:00

you can take any other projects that is

play06:02

using GitHub actions so if you see here

play06:03

similarly uh there is a DOT GitHub

play06:06

folder and if you go to dot GitHub

play06:08

folder again there is workflows folder

play06:10

okay if you go to a workflows folder

play06:12

you'll see that there are a bunch of

play06:13

pipelines here right one is CI build so

play06:16

it is building the CI then it is

play06:18

checking the code okay then image.aml

play06:20

after that uh like I mentioned you PR

play06:23

title check.yaml that means they are

play06:25

just verifying if the pr title is

play06:27

perfect or not then release.ml which

play06:29

will release and finally the sync which

play06:31

will verify like you know if your code

play06:33

has any if it is creating any

play06:35

vulnerabilities or if it is not adhering

play06:38

to any security standards so this

play06:40

pipeline will validate similarly you can

play06:42

also do n number of pipelines in your

play06:44

GitHub I mean dot GitHub Dot workflows

play06:47

and whatever actions that you configure

play06:49

so here you can say push comma pull

play06:52

request push comma pull request comma

play06:54

issues so GitHub does not mind executing

play06:57

your pipelines on the actions that that

play07:00

you are providing okay if you provide

play07:02

three actions it will just verify that

play07:03

okay either of the action has to be

play07:05

matched if either of the action is

play07:07

matched or if one of the actions is

play07:09

matched then your GitHub will start

play07:11

executing this pipeline okay now let us

play07:14

see how easy is it to write GitHub

play07:17

actions so you can also like I mentioned

play07:19

copy this repository and execute your

play07:21

first actions file so because many of

play07:24

our subscribers or viewers are familiar

play07:26

with python what I have decided is I'll

play07:28

write a very basic python uh addition

play07:31

example okay so what I have done is this

play07:33

is my srj folder and inside the SRC I

play07:37

created addition.py file okay so in this

play07:40

edition.py file what is there it's just

play07:42

a addition function and here I am

play07:45

testing the addition functionality okay

play07:46

so this is unit testing and this is your

play07:50

uh basic like you know addition program

play07:52

where it is saying addition function

play07:54

where it is saying uh past two variables

play07:56

and return the addition of two variables

play07:58

so I have tested this here now let me

play08:00

write a GitHub action so let me write a

play08:03

pipeline what this pipeline has to do is

play08:05

whenever there is a new commit that is

play08:07

getting created okay let's say let me do

play08:09

it in life okay what I'll do is I'll

play08:12

just modify something here I'll add a

play08:14

new comment

play08:15

this is a test commit now as soon as I

play08:19

commit what should happen is GitHub

play08:21

actions should check out this program

play08:24

okay or it has to check out this code

play08:26

and then it has to create a python

play08:29

environment for me right because uh

play08:31

there is no server that I did not

play08:33

configure any server in Jenkins you have

play08:35

your servers pre-configured right what

play08:37

you will do is either you'll use uh

play08:38

Docker containers which I explained in

play08:40

your previous class or else what you'll

play08:42

do is you will create your worker nodes

play08:44

and inside your worker nodes you will

play08:45

install Python and you will set up all

play08:47

the required environment and then

play08:49

finally what you'll do is you will run

play08:51

this program and then you will run your

play08:53

test so now I want everything to happen

play08:55

in GitHub actions let us see what GitHub

play08:58

actions does as soon as I click on the

play09:00

commit changes okay now what happens is

play09:02

just go to your root directory and you

play09:05

will see this hello button once you

play09:06

click on it it will say that your

play09:08

actions is running let me click on one

play09:10

of this I'll tell you why there are two

play09:11

actions but before that let us see what

play09:13

is happening

play09:14

okay firstly it set up the job now it

play09:18

said that it is checking out the code

play09:19

okay where is it getting this

play09:21

information from I wrote all of them in

play09:23

the CI file or in the pipelines file

play09:26

I'll show you that okay so run action

play09:29

slash checkout at the rate V3 what is

play09:31

this and what is it doing okay so it is

play09:34

basically a plugin that I am configuring

play09:37

in the uh pipeline.yaml or the ci.aml

play09:40

and I am saying GitHub that okay check

play09:43

out the repository after that I said set

play09:45

up python okay where it set up the

play09:48

python then I said install the

play09:50

dependencies if at all there is

play09:51

something but in my specific case there

play09:53

are no dependencies it's just a simple

play09:56

addition Dot py finally it has to run

play09:59

the test where it has to just execute

play10:01

the test that I showed you and then it

play10:04

says that the job is complete now let us

play10:06

see how did I do all of these things is

play10:09

it a big deal or does it take uh you to

play10:12

master GitHub actions no not at all so

play10:14

you can and just write all of these

play10:16

things in first five minutes like you

play10:18

know even if you watch this video you

play10:20

can after this video you can directly

play10:22

create your own GitHub repository and

play10:24

you can write this file it is that

play10:25

simple okay so it follows the yaml

play10:28

standard or yaml formatting so if you

play10:31

are aware of kubernetes or you know if

play10:32

you are already aware of yaml

play10:34

indentation and syntaxing then uh you

play10:38

it's a cakewalk for you so firstly

play10:40

provide the name of your GitHub action

play10:42

where I said this is my first GitHub

play10:44

actions after that like I mentioned you

play10:46

I said that on every commit okay I can

play10:48

change this event as well but I said on

play10:51

every comment just execute this GitHub

play10:52

actions then here start your actual

play10:55

execution okay job you can correlate it

play10:57

with as pipeline in Jenkins okay so here

play11:01

if you create three jobs that means you

play11:02

are running three Jenkins pipelines okay

play11:04

so even in one file you can write

play11:06

multiple jobs like you know in one file

play11:08

you are executing multiple pipelines

play11:09

it's up to you but here I just used uh I

play11:13

mean I just created one job and what I'm

play11:15

saying is use Ubuntu latest as the

play11:17

container image okay like if you

play11:20

remember previously what we have done is

play11:22

we configured uh in Jenkins pipeline

play11:25

that okay I have to use Docker as agent

play11:28

and once I use Docker as agent use this

play11:30

image okay it can be Ubuntu or it can be

play11:32

python or something like that so

play11:34

similarly here for GitHub actions also

play11:37

you will say Okay use Ubuntu latest

play11:39

image and inside that set up a python

play11:42

environment so now what I am saying is

play11:44

my addition functionality has to be

play11:47

verified on python 3.8 as well as python

play11:50

3.9 okay so that is the reason why you

play11:52

saw two jobs that were getting executed

play11:54

if I mention here Python 2.7 okay what

play11:58

will happen is now your python uh like

play12:01

your pipeline will be executed on three

play12:03

uh versions okay so that is again a

play12:06

flexibility that GitHub is offering you

play12:08

even if you don't want all of these

play12:10

things you can get rid of all of these

play12:12

things and just say that okay here in

play12:14

the python version just say python 3.8

play12:16

okay so what is the next step that I am

play12:19

doing is I am basically checking out the

play12:21

code okay so till here I did nothing I

play12:24

just said that okay uh use one of the

play12:27

environments that is Ubuntu latest that

play12:29

has python 3.8 and 3.9 like you know I

play12:32

want two environments after that here

play12:34

starts your steps where you write your

play12:36

actual code okay it's like stages in

play12:38

Jenkins right so in Jenkins you define

play12:40

multiple stages right you want your

play12:42

build stage you want your test stage you

play12:43

want your sash stage Dash stage and

play12:46

finally you say your deploy stage

play12:48

similarly you can also segregate your

play12:50

GitHub actions into multiple steps

play12:52

wherein first step I am saying the first

play12:55

step has to be to check out the code now

play12:57

where did I get this information from so

play12:59

this is a standard that you can follow

play13:00

if you don't know uh how to figure out

play13:03

these things like every time just go to

play13:06

your GitHub actions documentation

play13:08

okay so if you go to GitHub actions

play13:11

documentation so the documentation

play13:13

itself will tell you what are the

play13:15

plugins that GitHub actions provides

play13:17

okay so for example if you want to check

play13:19

out the code okay so go to your uh just

play13:22

click on the Kickstart and you will have

play13:24

bunch of plugins and bunch of examples

play13:26

in each example they'll explain you like

play13:29

you know for example to build and test

play13:31

okay so build and test go Application

play13:33

building test Java application with ant

play13:35

build and test uh Java application with

play13:38

Maven just open this one okay build and

play13:40

test Java application with Maven here

play13:42

you will see that you know what they are

play13:44

doing is firstly they are checking out

play13:46

the code so in this example and in my

play13:48

example the step is the same actions

play13:51

hyphen checkout version three the reason

play13:53

why is it same is because it's a plugin

play13:56

okay so it is not a configuration that

play13:58

you are writing by yourself it is just a

play14:00

plugin that you are using like I told

play14:02

you GitHub actions has a Marketplace of

play14:04

plugins and you can just use these

play14:06

plugins uh unlike in Jenkins what you

play14:08

will do you will go to your Jenkins

play14:10

manage plugins and you will install the

play14:12

plugins and you will do all of those

play14:13

things right but in GitHub actions the

play14:16

plugins are Auto installed like you know

play14:18

they are installed by default all that

play14:20

you need to do is whichever plugin that

play14:22

you want to use like in my case I said

play14:24

action setup python uh iterate version

play14:27

2. it doesn't mean python 2 it means uh

play14:29

like you know whenever you see at the

play14:31

rate it is the version of the plugin but

play14:33

it is not the version of your

play14:34

programming language or your tool okay

play14:37

so setup hyphen python at the Red

play14:39

Version 2 does not mean that you are

play14:40

installing python 2 but it means that

play14:42

you are using setup hyphen python plug

play14:45

in the version 2 of the plugin okay so

play14:48

if you compare it here it says setup

play14:50

hyphen Java at the rate V3 that means it

play14:53

is installing version 3 of the Java

play14:55

plugin okay so even if you see the

play14:57

syntax and you know the naming

play14:59

convention is quite similar if tomorrow

play15:01

you want to build a node.js application

play15:03

or let me take Ruby application here

play15:05

okay so all that that changes is you

play15:08

just have to modify setup Java to set up

play15:10

Ruby okay and you want to Define which

play15:12

version of the plugin that you want to

play15:14

use so so the biggest advantage of

play15:16

GitHub action is you will have to write

play15:18

very very less code okay because the

play15:21

configuration is quite similar for uh

play15:24

different applications whether it is

play15:25

python application Java application node

play15:27

application you are only playing with

play15:29

the plugins and those plugins are

play15:30

already installed but the only

play15:32

disadvantage is that these plugins are

play15:34

very limited in scope

play15:36

okay because GitHub action is very uh

play15:39

new right even though it is there for

play15:40

last three to four years but if you try

play15:43

to compare it with Jenkins or any other

play15:44

CD tools that CI CD tools that are

play15:47

available in the market so GitHub

play15:49

actions is still a budding tool if you

play15:50

compare it with it after you do this

play15:52

okay so setup python is done then you

play15:54

said actions python okay that means you

play15:57

just configured a python environment

play15:58

inside your Ubuntu latest what happens

play16:01

after that is you know you can write

play16:03

your steps what I am saying just install

play16:05

pip then install the pi test which

play16:08

through which I am going to test my

play16:09

application and finally just run the pi

play16:12

test

play16:12

so this is very simple way of writing

play16:15

GitHub actions so you can use this same

play16:17

example just like I told you for this

play16:19

repository clone it try it try it by

play16:21

yourself then look into the logs see

play16:23

what is happening you know this way you

play16:25

can understand GitHub actions in a

play16:27

better way and the other thing is that

play16:30

if you go to the settings okay so you

play16:32

have options for uh you know just go to

play16:35

actions here and then you can configure

play16:37

your custom Runners as well like let's

play16:39

say you don't want to use uh you know

play16:41

you can just click on it and say new

play16:43

self-hosted Runners using which you can

play16:45

create your own runners okay so uh

play16:48

similar to Jenkins right either you can

play16:50

use Docker containers or you can create

play16:52

your own host runners or you know you

play16:55

can create your own worker nodes and you

play16:56

can use on it let's say you are not

play16:58

happy with the default Runners that

play17:00

GitHub is providing because you can

play17:01

understand that these Runners are light

play17:03

in nature or you know they don't have

play17:05

enough compute resources you might want

play17:07

to do some load testing uh which GitHub

play17:09

access is not providing you that much

play17:11

compute so in such cases you can create

play17:13

your new self-hosted Runners even if you

play17:16

have issues with the security or

play17:18

something create your own self-hosted

play17:20

Runners and you can execute on your cell

play17:21

phone start Runners and there are things

play17:24

like GitHub actions provides integrated

play17:26

is you can also store your secrets if

play17:29

you go to my next example and see so

play17:32

again go to the examples folder so here

play17:35

I have one example which says how to

play17:37

deploy the Java application configure

play17:40

Maven sonar and finally deploy to

play17:42

kubernetes so one doubt that you should

play17:44

that you should get is okay so if I am

play17:47

doing the entire thing on GitHub actions

play17:49

where will I store the passwords like

play17:50

you know the cube config file so Cube

play17:52

config file has to be extremely secure

play17:54

you cannot share the cubeconfig file

play17:56

with someone else so what GitHub access

play17:58

does is it provides you the native

play17:59

support to store the secrets like you

play18:01

can go to the settings and you know you

play18:04

have an option to store your CI CD

play18:06

secrets and using that CI CDC Secrets

play18:09

what I've done is I have stored my

play18:11

cubeconfig file I've stored the sonar

play18:13

token any any secure information you can

play18:15

store and if you try to compare my

play18:18

previous example with this example there

play18:20

is not much difference okay so similarly

play18:22

I'm checking out code I am using one

play18:24

more plugin for kubernetes okay so this

play18:26

plugin information you can get from

play18:28

GitHub docs and you know I'm using the

play18:31

same steps okay so this step I am

play18:34

executing the payment Target in this

play18:35

step I am just executing the sonar

play18:37

related actions and finally I am using

play18:39

kubernetes

play18:40

tomorrow if you want to set up the same

play18:42

thing for your organization okay

play18:44

irrespective of any additional steps

play18:47

that you have the basic configuration or

play18:49

the basic skeleton you can just copy

play18:51

from my repository or you can just copy

play18:53

from the examples that I have shown you

play18:55

so that is the advantage of using GitHub

play18:57

actions now let me try to compare it

play19:00

with Jenkins because that is one of the

play19:02

important things that many people have

play19:04

the question like you know should I

play19:05

start with GitHub actions or should I

play19:07

start with Jenkins or should I Implement

play19:09

GitHub actions or Jenkins in my project

play19:11

so to fundamentally explain you one uh

play19:14

major disadvantage with GitHub actions

play19:16

is it is very uh scoped to the platform

play19:18

so in tomorrow I mean tomorrow if you

play19:20

want to move from one platform to

play19:22

another platform let's say GitHub to uh

play19:24

AWS code commit or from GitHub to you

play19:26

want to move to

play19:27

uh Azure devops okay so in such cases do

play19:30

not use GitHub access that is one of the

play19:32

disadvantage but if you come to the

play19:34

advantages like it can be an interview

play19:35

question so even I have provided the

play19:37

details here so if somebody is asking

play19:39

you what are the advantages of GitHub

play19:41

actions over Jenkins so you can simply

play19:43

say that the hosting okay so why what I

play19:46

mean by hosting is uh if you have to

play19:49

create your Jenkins instance uh like

play19:51

yesterday's class I showed you you have

play19:52

to create a ec2 instance then you have

play19:54

to install install Jenkins and then you

play19:56

have to expose your inbound traffic like

play19:59

you know you have to do bunch of the

play20:00

things you have to install the plugins

play20:01

you have to configure it and tomorrow if

play20:03

there is new version of Jenkins you also

play20:05

have to update it right if you don't

play20:06

update it you will run into security

play20:07

issues so this entire thing is gone with

play20:10

GitHub I mean the GitHub actions so you

play20:12

don't have maintenance effort you don't

play20:14

have hosting effort if your platform is

play20:16

only GitHub then the best thing that you

play20:18

can do is simply migrate to GitHub

play20:20

actions for all the open source projects

play20:22

that you will see 90 of the people use

play20:24

GitHub actions because of this

play20:25

flexibility that GitHub is providing so

play20:28

you don't need a uh another engineer who

play20:30

has to work as a Jenkins maintenance

play20:33

engineer

play20:34

okay after that the user interface like

play20:37

I showed you user interface and writing

play20:39

a Jenkins sorry GitHub actions uh

play20:42

pipeline is very very simple after that

play20:45

coming to the cost uh if you create a

play20:47

easy to instance if you create a worker

play20:49

nodes you configure Auto scaling groups

play20:50

all of these configurations is not cost

play20:53

effective right if you are using GitHub

play20:55

accents what am I doing GitHub actions

play20:57

is providing you free execution for

play20:59

public projects okay so if your code is

play21:01

open source and if you are a public

play21:03

project you don't even have to worry

play21:05

about it like GitHub actions is

play21:06

completely free whereas if you are a

play21:08

private project like let's say if I make

play21:10

this repository private so in such cases

play21:12

I think there is a limitation for 2000

play21:14

minutes of execution I don't remember

play21:16

exactly but there is a limitation on the

play21:19

private repositories if your

play21:20

organization is using private

play21:21

repositories then yeah you must also

play21:23

evaluate it in in terms of the cost but

play21:25

still uh even the cost will be less and

play21:28

you will not have the maintenance

play21:29

overhead of maintaining Jenkins okay not

play21:33

Jenkins just taking Jenkins because I'm

play21:36

trying to compare it with our previous

play21:37

video

play21:38

so these are some pros and cons you can

play21:40

also look into the details uh in the

play21:42

GitHub repository and finally what I

play21:44

wanted to tell you is uh like you know

play21:46

if you uh want to use a GitHub actions

play21:49

over Jenkins then if you are only public

play21:53

project open source project and if your

play21:56

project is not deciding to move from one

play21:58

place to another place in the future

play21:59

like from GitHub to any other VCS

play22:02

platforms then GitHub action is the

play22:04

right tool for you I hope you like the

play22:06

video if you have any feedback for me

play22:08

definitely uh put that in the comment

play22:10

section and don't forget to like and

play22:11

share this video with your friends thank

play22:13

you so much I'll see in the next video

play22:14

take care everyone bye

Rate This

5.0 / 5 (0 votes)

Ähnliche Tags
DevOpsGitHub ActionsCI/CDJenkinsDockerAutomationCode DeploymentMavenSonarKubernetesYAML
Benötigen Sie eine Zusammenfassung auf Englisch?