Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e5cdc77
Indent workflow_dispatch with pull_request in same alignment
ruhul-cs May 31, 2025
dfbe40b
Merge branch 'main' of github.com:ruhul-cs/docker-multi-stage-build
ruhul-cs May 31, 2025
b507efb
Dont allow CI Check [skip ci]
ruhul-cs May 31, 2025
9899784
Add comment to get secrect variable in a workflow
ruhul-cs Jun 2, 2025
97a97fd
Upload Artifact example workflow
ruhul-cs Jun 2, 2025
61b1503
Create and upload job artifact from github workflow
ruhul-cs Jun 2, 2025
cf4c72a
Create, upload and download job artifact from github workflow
ruhul-cs Jun 2, 2025
2e8bb49
Create, upload and download job artifact from github workflow
ruhul-cs Jun 2, 2025
7ed4e5e
Deploy download action from one runner to another runner
ruhul-cs Jun 2, 2025
198a816
Check upload action workflow
ruhul-cs Jun 2, 2025
9b88e51
Run npm run build command to check if sh file executes
ruhul-cs Jun 2, 2025
d3a9783
Execute artifact file and test
ruhul-cs Jun 2, 2025
875e9be
Add dependency caching step in the job
ruhul-cs Jun 3, 2025
e79836b
Execute job outputs in workflow
ruhul-cs Jun 3, 2025
460dcaa
Add dependency caching workflow example
ruhul-cs Jun 3, 2025
f236cdb
Setup envrionment variable and secrects in a workflow
ruhul-cs Jun 4, 2025
9abee36
Environment and env variable setup with security
ruhul-cs Jun 4, 2025
593e07f
Environment and env variable setup with security
ruhul-cs Jun 4, 2025
6318efa
Conditional workflow integration
ruhul-cs Jun 4, 2025
77aced3
Add a condition to check if the step fails
ruhul-cs Jun 4, 2025
fe73595
Add continue-on-error identifier in conditional workflow example
ruhul-cs Jun 4, 2025
cbe8bd6
Add failure function to continue next job
ruhul-cs Jun 4, 2025
1627cf3
Add container in the runner to run the workflow steps
ruhul-cs Jun 5, 2025
6e79786
Add Service container example
ruhul-cs Jun 5, 2025
c475281
Need more study on service container to run all the jobs and test
ruhul-cs Jun 5, 2025
5f27aea
Merge branch 'main' into main
MohammadRuhulAmin Jun 5, 2025
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
50 changes: 50 additions & 0 deletions .github/workflows/controlling-execution-flow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Other dependent jobs using "needs" would be cancelled / aborted
# if a previous job fails.
name: Conditional Jobs Example
on: workflow_dispatch

jobs:
lint:
runs-on: ubuntu-latest
container:
image: node:18
steps:
- name: Hellow
run: echo "Hellow"

job1:
runs-on: ubuntu-latest
container:
image: node:18
steps:
- name: job1
id: jobid-1
# continue-on-error helps to tell GitHub Actions to continue running subsequent steps even if this step fails
# continue-on-error: true | will experiment later
run: exit 1 # this statement forcfully fail the step
- name: execute failure message
## There are four functions
# 1. failure() returns true if a previous step or job fails
# 2. cancelled() returns true if a workflow has been cancelled
# 3. success() return true if none of the previous steps failed
# 4. always() returns true

if: failure() && steps.jobid-1.outcome == 'failure'
run: echo 'Process has been failed!'

job2:
needs: job1
runs-on: ubuntu-latest
container:
image: node:18
steps:
- name: job2
run: echo "job2"
job3:
needs: job2
runs-on: ubuntu-latest
container:
image: node:18
steps:
- name: job3
run: echo "job3"
25 changes: 25 additions & 0 deletions .github/workflows/dependency-caching-workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: dependency caching example
on : workflow_dispatch

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Get code
uses: actions/checkout@v4
# Before installing the dependencies we will cache that
# The ~/.npm folder is cached using actions/cache@v3 to speed up dependency installation.
# The cache is not stored on a specific cloud machine — instead, it is stored in GitHub's cache storage, linked to a specific key.
# The key is generated based on the hash of your package-lock.json file:
# key: node-modules-${{ hashFiles('**/package-lock.json') }}
# As long as the contents of package-lock.json do not change, the key remains the same, and the cache is reused in future runs.
# If package-lock.json changes, a new key is generated, and a new cache is created.
# Each GitHub-hosted runner is a fresh virtual machine. Nothing is saved on the machine itself after the job finishes.
# The dependencies are restored from GitHub’s cache (not the machine) and reused across runs until the key changes.
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: node-modules-${{ hashFiles('**/package-lock.json') }}
- name: Install dependency
run: npm ci
38 changes: 38 additions & 0 deletions .github/workflows/env-example-workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Environment and env variable setup with security
on: workflow_dispatch
# We can declare env variable on workflow level sothat all the jobs can access the keys

jobs:
test:
# Add environment for the project
environment: development
# env variable for this specific job and not shared to other job
# environment variable declaration on job level
env:
MONGODB_CLUSTER_ADDRESS: ${{ secrets.MONGODB_CLUSTER_ADDRESS }}
# if it is a secrect MONGODB_PASSWORD: ${{ secrets.MONGODB_PASSWORD }}
MONGODB_USERNAME: ${{ secrets.MONGODB_USERNAME }}
MONGODB_PASSWORD: ${{ secrets.MONGODB_PASSWORD }}
PORT: ${{ secrets.PORT }}
runs-on: ubuntu-latest
steps:
- name: Get Code
uses: actions/checkout@v3
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: npm-deps-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
run: npm ci
- name: Output information
run: echo "..."
- name: Print variables
run: echo "Project name is ${{ vars.PROJECT_NAME }}"
deploy:
needs: test
runs-on: ubuntu-latest
steps:
- name: Output information
run: |
echo "..."
24 changes: 24 additions & 0 deletions .github/workflows/job-outputs-workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
### One job can produce an output
### that will help in another job.
### Custom actions
name: Job output actions
on: workflow_dispatch
jobs:
test:
runs-on: ubuntu-latest
outputs:
random-number: ${{ steps.generate-random.outputs.rand }}
steps:
- name: Generate a random number
id: generate-random
run: |
min=50
max=150
echo "rand=$(( RANDOM % (max - min + 1) + min ))" >> "$GITHUB_OUTPUT"
echo "$GITHUB_OUTPUT"
deploy:
needs: test # To use a job output i have to use needs key and mention the job name
runs-on: ubuntu-latest
steps:
- name: Print the rand value from test job
run: echo "The random number that generated from test job is ${{ needs.test.outputs.random-number }}"
35 changes: 35 additions & 0 deletions .github/workflows/service-container-workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
## Need to study more on
## https://www.udemy.com/course/github-actions-the-complete-guide/learn/lecture/34140318#content


name: Service container workflow
on: workflow_dispatch

jobs:
Service-Container:
runs-on: ubuntu-latest

services:
no-sqldb:
image: mongo
env:
MONGO_INITDB_ROOT_USERNAME: xx
MONGO_INITDB_ROOT_PASSWORD: 1223
ports:
- 27017:27017

sql-db:
image: mysql
env:
MYSQL_ROOT_PASSWORD: 12
MYSQL_USER: Tests
MYSQL_PASSWORD: 12
ports:
- 3306:3306

container:
image: node:18

steps:
- name: Run some command
run: echo "this is a command example...!"
13 changes: 13 additions & 0 deletions .github/workflows/service-order-workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Service order workflow example
on: workflow_dispatch

jobs:
example:
runs-on: ubuntu-latest
services:
# Side containers (run first)
container:
# Main execution container (run second)
steps:
# Run commands inside main container

64 changes: 64 additions & 0 deletions .github/workflows/upload-artifact-workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# --------------------------------------------------------------------
### What is JOB Artifact ?
## Official documentation url :
## https://github.com/actions/upload-artifact
# In Github Actions job artifact is a feature that helps to generate
# a file or output or executable file to store and download or to
# use it for other job.
# -------------------------------------------------------------------

name: Job Artifact Store in GitHub Repository
on:
push:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Get Code
uses: actions/checkout@v4
- name: Install dependencies
run: npm ci
build:
needs: test
runs-on: ubuntu-latest
steps:
- name: Get code
uses: actions/checkout@v4
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.npm # This is the home directory of the runner
key: deps-node-module-${{ hashFiles('**/package-lock.json') }} # must provide key for dependency caching
- name: Install dependencies
run: npm ci
- name: Build WebSite
run: npm run build
- name: upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist-file # this is the artifact name (ref-a)
path: | # the location of the file # downloading the package.json file
dist
package.json

deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download the artifact from build job workflow
uses: actions/download-artifact@v4
with:
name: dist-file # to download from another job, the name must be same as given
# (ref-a)
- name: Check the working directory of the runner
run: pwd
- name: See all the files in a folder
run: ls -a
- name: Run npm build command
run: npm run build
- name: Go to dist and Execute executioner.sh file
run: cd dist && ./executioner.sh
- name: Deploy the artifact
run: echo "deploy successful..!"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ package-lock.json
.db-cred
nginx/nginx-selfsigned.crt
nginx/nginx-selfsigned.key
/dist
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"scripts": {
"start": "node src/app.mjs",
"test": "vitest",
"lint": "eslint ."
"lint": "eslint .",
"build":"rm -rf dist && mkdir dist && cd dist && echo echo 'deployment running....' >> executioner.sh && chmod +x executioner.sh"
},
"author": "",
"license": "ISC",
Expand Down
11 changes: 11 additions & 0 deletions public/documentation/github.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,14 @@ Example:

### SKIP CI using git commit
- [skip ci] Example: git commit -m "Dont allow CI Check [skip ci]"



### Dependency Caching
- The packages to install take too much time sometimes. To reduce the time can
be a game changer. Dependency caching can be a greate choice. If we cache those dependencies the time of deployment can dramatically reduced.


Get Code --> Install Dependency --> Test App

Get Code --> Install Dependency --> Build Project