Learn GitHub Actions
Learn GitHub Actions
Roadmap
Blue is the colour of the
clear sky and the deep Red is the colour of Black is the color of
sea danger and courage ebony and of outer space
1 3 5
2 4 6
Yellow is the color of gold, White is the color of milk Blue is the colour of the
butter and ripe lemons and fresh snow clear sky and the deep
sea
3
Learning GitHub
Actions
Git Overview
Git
✘ Git is a distributed version control system (DVCS) that allows
multiple developers or other contributors to work on a project.
✘ It provides a way to work with one or more local branches and push
them to a remote repository.
8
Git
git status
git add .
git commit -m "commit message"
git pull
git push
git log
git branch
git checkout
git merge
Git Architecture
GitHub
GitHub is a cloud platform that uses Git as its core technology. It
simplifies the process of collaborating on projects and provides a
website, command-line tools, and overall flow that allows developers
and users to work together. GitHub acts as the "remote repository" in
the Git section.
Key features provided by GitHub include
✘ Issues
✘ Discussions
✘ Pull requests
✘ Notifications
✘ Labels
✘ Actions
✘ Forks
✘ Projects
Key features provided by GitHub include
Issues Blue Red
Is the color of gold, butter and ripe Is the colour of the clear sky and the Is the color of blood, and because of
lemons. In the spectrum of visible deep sea. It is located between this it has historically been
light, yellow is found between green violet and green on the optical associated with sacrifice, danger
and orange. spectrum. and courage.
13
GitHub
GitHub is a development platform that enables you to host and review
code, manage projects, and build software alongside 50 million
developers.
Issues
Issues are where most of the communication between a project's
consumers and development team occurs.
✘ This provides a clear audit trail for anyone reviewing the history of a
file or linked item, such as an issue or pull request.
Discussions
GitHub Discussions is a collaborative communication forum for the
community around an open source project. Community members can
ask and answer questions, share updates, have open-ended
conversations, and follow along on decisions affecting the community's
way of working.
Pull Requests
A pull request is the mechanism used to signal that the commits from
one branch are ready to be merged into another branch.
GitHub Tags
Tags are associated with commits, so you can use a tag to mark an
individual point in your repository's history, including a version number
for a release.
Labels
Labels provide a way to categorize and organize issues and pull
requests in a repository.
✘ You can create workflows that build and test every pull request to your repository, or
deploy merged pull requests to production.
✘ GitHub Actions goes beyond just DevOps and lets you run workflows when other
events happen in your repository.
What is GitHub Action Workflow
✘ A workflow is a configurable automated process
that will run one or more jobs.
✘ Pull request
Action3
ü GitHub Action Workflow Directory: .github/workflows/
ü File Extension: .yml
Add Label
Vijay Saini
Events
✘ An event is a specific activity in a repository that triggers a workflow run.
✘ For example, activity can originate from GitHub when someone creates a pull
request, opens an issue, or pushes a commit to a repository.
✘ You can also trigger a workflow run on a schedule, by posting to a REST API, or
manually.
GitHub Jobs
GitHub Jobs
A job is a set of steps in a workflow that execute on the same runner.
Each step is either a shell script that will be executed, or an action that
will be run.
Step
Steps can run commands, run setup tasks, or run an action
Checkout Repository
Build Application
Test Application
Upload Artifacts
✘ An action can pull your git repository from GitHub, set up the correct
toolchain for your build environment, or set up the authentication to your
cloud provider.
What is GitHub Action
✘ GitHub Actions helps you automate your software development workflows
from within GitHub. You can deploy workflows in the same place where you
store code and collaborate on pull requests and issues.
✘ Event Trigger
✘ Job
✘ Step
✘ Runner
Use an action to help reduce the amount of repetitive code that you
write in your workflow files.
You can write your own actions, or you can find actions to use in your
workflows in the GitHub Marketplace.
GitHub Action
dd
GitHub Runner
Runners
✘ A runner is a server that runs your workflows when they're triggered.
Each runner can run a single job at a time.
✘ Free GitHub plan + per-minute rates ✘ Are free to use with GitHub Actions
✘ Provide a clean instance for every job ✘ Don't need to have a clean instance for every
execution. job execution.
Why Self-hosted Runners
✘ Software Dependency
ApplicationService = ‘http://github-action-is-awesome.com’
Create http://github-action-is-awesome.com
Deploy my app to http://github-action-is-awesome.com o Create ApplicationService
Perform UAT on http://github-action-is-awesome.com o Deploy my app to ApplicationService
Perform Load testing on http://github-action-is-awesome.com o Perform UAT on ApplicationService
o Perform Load testing on ApplicationService
Environment Variables
We can use environment variables to store information that you want to reference in your workflow.
GitHub Secretes
Secrets are encrypted environment variables that you create in an
organization, repository, or repository environment. The secrets that
you create are available to use in GitHub Actions workflows.
GitHub uses a libsodium sealed box to help ensure that secrets are
encrypted before they reach GitHub and remain encrypted until you
use them in a workflow.
GitHub Environments
Using environments for deployment
PRODUCTION_APP_SECRET
STAGE_APP_SECRET
QA_APP_SECRET
UAT_APP_SECRET
DEV_APP_SECRET
GitHub Environments
Environments are used to describe a general deployment target like
production, staging, or development.
You can configure environments with protection rules and secrets. A workflow
job that references an environment must follow any protection rules for the
environment before running or accessing the environment's secrets.
Artifacts
Artifacts
Artifacts allow us to share data between jobs in a workflow and store data once that
workflow has completed.
Downloading files: You can only download artifacts that were uploaded
during the same workflow run. When you download a file, you can
reference it by name.
Artifacts
Infra Automation
Infrastructure Requirement
Resource Specification
✘ Inconsistencies in Deployments
✘ Labor Intensive
✘ Human Error
✘ Slow Process
Why Infrastructure as a code ?
✘ Avoid manual configuration to enforce consistency
✘ Idempotence
https://docs.microsoft.com/en-us/azure/azure-resource-manager/bicep/install
Bicep Decompile vs Build
GitHub
IaC Setup Action
Template Authentication Workflow
Azure AD service principals for automation authentication
.gitignore file is a text file that tells Git which files or folders to ignore in
a project.
Login to Deploy
Setup Docker Docker
Docker the
Docker Build Push
Registry image
custom actions
Vijay Saini
custom actions
Actions are individual tasks that you can combine to create jobs and customize your workflow. You can
create your own actions, or use and customize actions shared by the GitHub community.
Composite Actions
A composite action allows you to combine multiple workflow steps within one action. For example, you
can use this feature to bundle together multiple run commands into an action, and then have a
workflow that executes the bundled commands as a single step using that action. To see an example,
check out "Creating a composite action".