Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notes of your course #8

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
0dd042b
Create Git_&_Github_Crash_Course.md
BaliDataMan May 30, 2024
7558b9d
Update Git_&_Github_Crash_Course.md
BaliDataMan May 30, 2024
2871adb
Update Git_&_Github_Crash_Course.md
BaliDataMan May 30, 2024
62068d3
Create Availability-&-Pricing
BaliDataMan Jun 5, 2024
86a97ea
Create Running Multi-Line Shell Commands.md
BaliDataMan Jun 5, 2024
0b5bd68
Create README.md
BaliDataMan Jun 5, 2024
4e17fed
Update README.md
BaliDataMan Jun 5, 2024
641afc0
Update README.md
BaliDataMan Jun 5, 2024
b6d5463
Update README.md
BaliDataMan Jun 6, 2024
4822d27
Update Git_&_Github_Crash_Course.md
BaliDataMan Jun 6, 2024
8253aaf
Rename Git_&_Github_Crash_Course.md to Git-&-Github-Crash-Course.md
BaliDataMan Jun 6, 2024
19a8e88
Update Git-&-Github-Crash-Course.md
BaliDataMan Jun 6, 2024
1221ca9
Update Git-&-Github-Crash-Course.md
BaliDataMan Jun 7, 2024
419828d
Update Git-&-Github-Crash-Course.md
BaliDataMan Jun 10, 2024
ff9fa8b
Update Git-&-Github-Crash-Course.md
BaliDataMan Jun 10, 2024
dccb331
Create 01- Github Actions Basic Building blocks and Components.md
BaliDataMan Jun 23, 2024
4b38382
Create Workflows & Events Deep Dive.md
BaliDataMan Jun 23, 2024
a9735d5
Rename Workflows & Events Deep Dive.md to 02-Workflows & Events Deep …
BaliDataMan Jun 23, 2024
e111de5
Create manual.yml
BaliDataMan Jun 25, 2024
5ab4edc
Update 01- Github Actions Basic Building blocks and Components.md
BaliDataMan Jun 25, 2024
74931f2
Update 01- Github Actions Basic Building blocks and Components.md
BaliDataMan Jun 25, 2024
eb45571
Update 02-Workflows & Events Deep Dive.md
BaliDataMan Jun 27, 2024
9df50ea
Update README.md
BaliDataMan Jun 27, 2024
f650364
Update 02-Workflows & Events Deep Dive.md
BaliDataMan Jun 27, 2024
c832da3
Update 02-Workflows & Events Deep Dive.md
BaliDataMan Jun 27, 2024
ad086c4
Update 02-Workflows & Events Deep Dive.md
BaliDataMan Jun 27, 2024
8e2d5cd
Update 02-Workflows & Events Deep Dive.md
BaliDataMan Jun 27, 2024
b37bbc0
Create 03 Job Artifacts & Outputs
BaliDataMan Jun 27, 2024
53a4dcc
Rename 03 Job Artifacts & Outputs to 03-Job Artifacts & Outputs
BaliDataMan Jun 27, 2024
54e0bcb
Rename Git-&-Github-Crash-Course.md to 0-Git & Github Crash Course.md
BaliDataMan Jun 27, 2024
ee7ab80
Update README.md
BaliDataMan Jun 27, 2024
84a23bf
Update and rename 03-Job Artifacts & Outputs to 03-Job Artifacts & Ou…
BaliDataMan Jul 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/manual.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This is a basic workflow that is manually triggered

name: Manual workflow

# Controls when the action will run. Workflow runs when manually triggered using the UI
# or API.
on:
workflow_dispatch:
# Inputs the workflow accepts.
inputs:
name:
# Friendly description to be shown in the UI instead of 'name'
description: 'Person to greet'
# Default value if no value is explicitly provided
default: 'World'
# Input has to be provided for the workflow to run
required: true
# The data type of the input
type: string

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "greet"
greet:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Runs a single command using the runners shell
- name: Send greeting
run: echo "Hello ${{ inputs.name }}"
155 changes: 155 additions & 0 deletions 0-Git & Github Crash Course.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
1. Download and install Git on your system: https://git-scm.com/download

<br/>
<br/>

2. Configuring Git

After installing Git, you can also configure it - most importantly, you can set a username and email address that will be connected to all your code snapshots.

- This can be done via:
```
git config --global user.name "your-username"
git config --global user.email "your-email"
```
You can learn more about Git's configuration options here: https://git-scm.com/docs/git-config

Incase to check all the git global configurations, hit:
```
git config --list
```

And to know more about git commands or want to look into any specific git command, hit:
```
git help
```

<br/>
<br/>
<br/>
<br/>

<h1>Git Commands</h1>
<br/>
<br/>
<br/>
<br/>
3. When you have some new code repo on your local system , so as a first step you should open a terminal and set the location to the repo's folder and then hit

```
git int # this will intiallize the project in git by creating invisble .git folder
```
<img width="842" alt="image" src="https://github.com/BaliDataMan/github-actions-course-resources/assets/29046663/db6f3fb8-922d-4947-902e-0d960e6acf92">

<br/>
<br/>

4. Stagging files and creating commits
<img width="1315" alt="image" src="https://github.com/BaliDataMan/github-actions-course-resources/assets/29046663/a7681c5d-ce70-4c59-bdeb-2c8431fe240a">

- these commits are created so that you can anytime go back to any of these commits..
- from above image we learned
- **git add <File(01) NAME> <File(02) NAME> <File(03) NAME>**: it will set the stage to commit
- Another way to stage all files at ones is "**git add .**" or "git add *" . Downside of this approach is that it add all the files in the repo which may include any unwanted files.. and so you can add ".gitignore" file and mention files which you want git to ignore and Hence now you can use "git add ." and it will add only the required files and ignore the unwanted files(refere point # 9)
- **git commit -m " ENTER YOUR MESSAGE HERE "**: it will commit the file(s) to git(not to github)
- **git status**: it provide current status like is the file in stagging or commited, what all files etc..
- **git log**: it will provide you all the commits you have done so far, with date-time and Unique ID of that commit...


<br/>
<br/>
5. Multiple Commits and Checking out Snapshots

<img width="1315" alt="image" src="https://github.com/BaliDataMan/github-actions-course-resources/assets/29046663/c19bccb6-8267-439f-be34-43d3f6fd96cf">

- **git checkout <Commit ID # >** : it will change the "code" to the snapshot of that "commit id only" from the "latest code base". And if you check status (git status) "head" directs to the "commit id" which we provide. By default git "head" directs to latest "commmit id".

- **git checkout main** : By anytime if you want to restore and go back to the latest head, just checkout to "main"(means "main branch") will restore everything. and now you will see the "code base" is again back to the previous latest state and you can check all the commits or status by "git status" where "head" will direct to the latest commit..

**NOTE** - the git checkout is not delete anything, but it was tempraray change in commits..


<br/>
<br/>
6. Undo Commits or Reverting changes with "Git revert"

<img width="1300" alt="image" src="https://github.com/BaliDataMan/github-actions-course-resources/assets/29046663/db1dca3b-e62d-45c5-ad1f-9905f159fb79">

- From above image, if you have to revert the commint "C6", then by using "git revert < id-of-C6 >" this will create new commit as "C7" as shown form above figure. Note - its not deleting "C6", instead just creating new "C7".

- **git revert <Commit ID # >** - it will revert the changes of commit by creating new commit (which is just absent of revert code). In one word it Undo commit



<br/>
<br/>
7. Removing commits or Resetting code with "git reset"

- **git reset --hard <Commit ID # >** : to will delete all the commits which are before mentioned commit ID..
- For we have commits C1,C2,C3,C4,C5,C6 and now if you run "git reset --hard <C3 ID # >". It will delete C4, C5,C6 and we have following commits: C1, C2, C3 available only...


8. All the above Key commands in Git
<img width="1251" alt="image" src="https://github.com/BaliDataMan/github-actions-course-resources/assets/29046663/6de5942b-a687-4bc1-9224-ac190fcfbeb7">



9. Stagging Multiple files and ignoring with .gitignore
<img width="1114" alt="image" src="https://github.com/BaliDataMan/github-actions-course-resources/assets/29046663/b73fb92a-da40-4fad-b5ea-e369c84d27d8">

- Create ".gitignore" file in your repository and include all the files names which you wanted to be ignored by git and not pushed, as shown in above image, which is ".vscode" and ".DS_Store"
- now you can use "git add ." that this will stack all the files at ones and ignores all the files which are mentioned in the .gitignore file.



<br/>
<br/>
<br/>
<br/>

<h1>Branches</h1>
<br/>
<br/>
<br/>
<br/>


10. Understanding the Git Branches

<img width="896" alt="image" src="https://github.com/BaliDataMan/github-actions-course-resources/assets/29046663/f2dcd4d8-3315-4b1f-955f-6324dfba7d1a">

- When you intiatlize the git project with "git init", you get by default "main" branch(will contains all your commits)
- **git branch < Name of Branch>** : it will create new branch, by default this will take your latest commit(as starting point) and create new branch, as shown above for "C2" commit for branch "feature-1" and then you can shift to new branch with **git checkout < Name of Branch** (eg git checkout feature-1)
- **git checkout -b < Name of Branch>** : this is alternate way of creating new branch and started using it right away..
- **git branch** : it will share all the exsisting branches names (with current branch name in green coloured and star)
- **git branch -D < Name of Branch>** : it will delete the branch.
- **git merge < Name of Branch>** : it will merge name mentioned in the command with the current active branch and automatically try to resolve the conflicts, for example as shown in above image we can merge "feature-1" to "main" branch. then acivate main branch by "git checkout main"(and check current branch by git log, main branch should be activate) and then merge "feature-1" with main branch by git merge "feature-1" .. now after successful merged, this will show "how many files changed? how many lines added and delted"


<br/>
<br/>
<br/>
<br/>

<h1>Github</h1>
<br/>
<br/>
<br/>
<br/>


11. Github Intro
<img width="1265" alt="image" src="https://github.com/BaliDataMan/github-actions-course-resources/assets/29046663/564561ea-6fe8-4a0c-ae4c-a2c965db0d82">


11. Connecting Local and Remote Repositories
<img width="1222" alt="image" src="https://github.com/BaliDataMan/github-actions-course-resources/assets/29046663/62c9bd6c-3f2e-4e22-9625-5f95996b0c2b">

```
git remote add <Local repo Name> <github repo link>: #this will connect github to local git repository(eg git remote add origin https:github.com/abc/xyz.git)

```



12. pushing commit to github and understanding
102 changes: 102 additions & 0 deletions 01- Github Actions Basic Building blocks and Components.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<h1>Github Actions Basic Building blocks and Components</h1>

- Basic Buidling blocks of Github Actions:
<img width="897" alt="image" src="https://github.com/BaliDataMan/github-actions-course-resources/assets/29046663/8a90460d-ba50-4f17-be06-19e33e52f5ad">

- By Default each job run parallely and hence have its own runner.
```
job:
test: #job 1
runs-on: ubuntu-latest #runner 1
..
..

deploy: #job 2
runs-on: ubuntu-latest #runner 2
..
..
```
- To make run jobs sequentially we have to just add "needs"
```
job:
test: #job 1
runs-on: ubuntu-latest #runner 1
..
..

deploy: #job 2
needs: test #"deploy" job needs "test" to execute first and if it fails, "deploy" job will not execute, which makes it sequential..
runs-on: ubuntu-latest #runner 2
..
..
```
- Multiple event triggers, add all the ways of trigger under "on"
```
name: Deploy Project
on: [push, workflow_dispatch] #here "push" means whenever pushing code, "workflow_dispatch" means manually running the work..
jobs:
```
- Expression and Context Objects
```
name: Output information
on: workflow_dispatch
jobs:
info:
runs-on: ubuntu-latest
steps:
- name: Output GitHub context
run: echo "${{ toJSON(github) }}" #expression. to make it readbale wrapped with function "toJSON()"
```
- To know about Github Action Context objects: https://docs.github.com/en/actions/learn-github-actions/contexts
- Just like we used above exmaple "github" which is context object..
- To know about Github Actions Expression/Function: https://docs.github.com/en/actions/learn-github-actions/expressions
- Just like we used above exmaple "${{ toJSON(github) }}" which is Expression..

- Official Github Actions Doc: https://docs.github.com/en/actions

- On Github Marketplace we have two options: Apps and Actions:
- Here is Github Action Marketplace : https://github.com/marketplace?type=actions

- Github Checkout Action:
- Repo: https://github.com/actions/checkout?tab=readme-ov-file
- Marketplace: https://github.com/marketplace/actions/checkout

```
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Get code
uses: actions/checkout@v3 #"actions/checkout" define the name and "v3" is the version of teh action
#we can also add more parameters to the checkout action with "with" command refer here: https://github.com/marketplace/actions/checkout#usage
```

- **Failing and Analysizing Workflows:** To understand any worflow or just to undestand if whats happening underthe worflow, always refer to the logfile of the workflow which is visible after your workflow executes under the "Actions" tab.

<h2> Errors </h2>

1. **Error to push github actions worflow from local to github**:

To have access to push Github Action workflows from local system to Github you need to have "developer token" which have access to not just repository but also to workflow, which you can create it from here: https://github.com/settings/tokens (if there are other tokens as well remove them for you) and tick the workflow aswell, as shown in below image:

<img width="662" alt="image" src="https://github.com/BaliDataMan/github-actions-course-resources/assets/29046663/d990802a-ff47-40c2-aedf-8ae9f00fc2a0">


Now you have createed new token using which you can push the github workflow to github..


<h2> Summary: Github Actions Basic Building blocks and Components</h2>

<img width="1280" alt="image" src="https://github.com/BaliDataMan/github-actions-course-resources/assets/29046663/19745d8d-dcaa-4c41-9d22-3b2e8174c9e0">

- Final Deployment Code - https://github.com/BaliDataMan/github-actions-course-resources/blob/main/Code/02%20Basics/03%20Finished%20Project/.github/workflows/deployment.yml
<img width="1086" alt="image" src="https://github.com/BaliDataMan/github-actions-course-resources/assets/29046663/62e981fd-8890-4ccc-8ee1-5a5b1ecef74b">


- Another 2 deployments exmaples:
- Deployment 01: https://github.com/BaliDataMan/github-actions-course-resources/blob/main/Code/02%20Basics/05%20Practice%20Project%20(Finished)/.github/workflows/deployment1.yaml
<img width="1095" alt="image" src="https://github.com/BaliDataMan/github-actions-course-resources/assets/29046663/499412eb-7b69-4d0e-92c9-1214bbc57dd8">


- Deployment 02: https://github.com/BaliDataMan/github-actions-course-resources/blob/main/Code/02%20Basics/05%20Practice%20Project%20(Finished)/.github/workflows/deployment2.yaml
<img width="1077" alt="image" src="https://github.com/BaliDataMan/github-actions-course-resources/assets/29046663/95fc3315-6606-44b2-845d-e9f09217da11">
Loading