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

create-a-feature #241

Open
wants to merge 60 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
05d79cc
Create hello.yml
tuongroth Oct 15, 2024
ebab573
Create main.yml
tuongroth Oct 15, 2024
0f0ea29
Update hello.yml
tuongroth Oct 15, 2024
0a9b2e1
Create pipeline.yml
tuongroth Oct 15, 2024
b043615
Update pipeline.yml
tuongroth Oct 16, 2024
60a472a
Update pipeline.yml
tuongroth Oct 16, 2024
346b7bd
Update pipeline.yml
tuongroth Oct 16, 2024
677b7ac
Update pipeline.yml
tuongroth Oct 16, 2024
b31a546
Update pipeline.yml
tuongroth Oct 16, 2024
8800805
Update pipeline.yml
tuongroth Oct 16, 2024
cd0b04c
Update pipeline.yml
tuongroth Oct 16, 2024
87856ad
Update pipeline.yml
tuongroth Oct 16, 2024
cff5a22
Update pipeline.yml
tuongroth Oct 16, 2024
a45ef03
Update pipeline.yml
tuongroth Oct 16, 2024
06cac84
Update pipeline.yml
tuongroth Oct 16, 2024
aa0127f
Update pipeline.yml
tuongroth Oct 16, 2024
2d27d0e
Update pipeline.yml
tuongroth Oct 16, 2024
7619b4b
Create secrect.yml
tuongroth Oct 16, 2024
653af50
Update secrect.yml
tuongroth Oct 16, 2024
2c313dd
Update pipeline.yml
tuongroth Oct 16, 2024
e576361
Update pipeline.yml
tuongroth Oct 16, 2024
46955cd
Create fly.toml
tuongroth Oct 16, 2024
c146fc4
Create fly.yml
tuongroth Oct 16, 2024
e88d69d
Update pipeline.yml
tuongroth Oct 16, 2024
4918262
Create deployy.yaml
tuongroth Oct 16, 2024
a745842
Update secrect.yml
tuongroth Oct 16, 2024
2a8acc9
Update secrect.yml
tuongroth Oct 16, 2024
74b4703
Update secrect.yml
tuongroth Oct 16, 2024
72e2fce
Update secrect.yml
tuongroth Oct 16, 2024
d05ce95
Update pipeline.yml
tuongroth Dec 4, 2024
9baaf99
Update pipeline.yml
tuongroth Dec 4, 2024
5cdc51e
Create exercise11.1.md
tuongroth Dec 4, 2024
ef218d7
Update pipeline.yml
tuongroth Dec 4, 2024
814e835
Update pipeline.yml
tuongroth Dec 4, 2024
0c428ad
Update pipeline.yml
tuongroth Dec 4, 2024
ec72728
Update pipeline.yml
tuongroth Dec 4, 2024
d9a7a3b
Update pipeline.yml
tuongroth Dec 4, 2024
50b260b
Update pipeline.yml
tuongroth Dec 4, 2024
a855979
Update pipeline.yml
tuongroth Dec 4, 2024
8f5bc3a
Update pipeline.yml
tuongroth Dec 4, 2024
bb811bd
Update secrect.yml
tuongroth Dec 4, 2024
741ee91
Update pipeline.yml
tuongroth Dec 4, 2024
2ada9de
Update fly.yml
tuongroth Dec 4, 2024
542fb5a
Update deployy.yaml
tuongroth Dec 4, 2024
10e7272
Update fly.yml
tuongroth Dec 4, 2024
d8a4cb6
Update fly.yml
tuongroth Dec 4, 2024
0fe4d14
Update deployy.yaml
tuongroth Dec 4, 2024
b6f630a
Update deployy.yaml
tuongroth Dec 4, 2024
ffbeeef
Update deployy.yaml
tuongroth Dec 4, 2024
ef3372d
Rename deployy.yaml to deployy.yaml
tuongroth Dec 4, 2024
3c23a63
Update secrect.yml
tuongroth Dec 4, 2024
5eb29e0
Update secrect.yml
tuongroth Dec 4, 2024
769649e
Update secrect.yml
tuongroth Dec 4, 2024
dda7e35
Update fly.yml
tuongroth Dec 4, 2024
350b6ca
Update README.md
tuongroth Dec 6, 2024
e192e3e
Update README.md
tuongroth Dec 6, 2024
71cc18a
Update main.yml
tuongroth Dec 6, 2024
d8afb0d
Update main.yml
tuongroth Dec 6, 2024
de2a0f7
Update pipeline.yml
tuongroth Dec 6, 2024
cffb7f4
Update PokemonPage.jest.spec.jsx
tuongroth Dec 6, 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
60 changes: 60 additions & 0 deletions .github/workflows/deployy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Deployment Pipeline with Notifications

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build_and_deploy:
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '16'

- name: Install dependencies
run: npm install

- name: Run tests
run: npm test

- name: Deploy to production
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
run: |
echo "Deploying application..."
# Add your deployment commands here

notify:
needs: build_and_deploy
runs-on: ubuntu-20.04
steps:
- name: Send Discord success notification
if: ${{ success() }}
uses: Ilshidur/action-discord@2.0.2
with:
webhook: ${{ secrets.DISCORD_WEBHOOK_URL }}
message: |
:tada: **Deployment Successful!**
The latest version has been successfully deployed to production.
Commit: `${{ github.sha }}`
Branch: `${{ github.ref_name }}`

- name: Send Discord failure notification
if: ${{ failure() }}
uses: Ilshidur/action-discord@2.0.2
with:
webhook: ${{ secrets.DISCORD_WEBHOOK_URL }}
message: |
:x: **Deployment Failed!**
Something went wrong during the deployment process.
Commit: `${{ github.sha }}`
Branch: `${{ github.ref_name }}`
Please review the logs for more details.
15 changes: 15 additions & 0 deletions .github/workflows/fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
app = "part3-notes-backend-part4-8"
primary_region = "arn"

[http_service]
auto_start_machines = true
auto_stop_machines = true
force_https = true
internal_port = 3_001
min_machines_running = 0
processes = [ "app" ]

[[vm]]
cpu_kind = "shared"
cpus = 1
memory = "1gb"
60 changes: 60 additions & 0 deletions .github/workflows/fly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: CI/CD Pipeline

on:
push:
branches:
- main
pull_request:
branches: [main]

jobs:
test_and_lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

# Backend Tests
- name: Set up Node.js for backend
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Install backend dependencies
run: |
cd backend
npm install
- name: Run backend tests
run: |
cd backend
npm test

# Frontend Tests
- name: Set up Node.js for frontend
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Install frontend dependencies
run: |
cd frontend
npm install
- name: Run frontend tests
run: |
cd frontend
npm test

deploy:
needs: [test_and_lint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

# Deploy Backend
- name: Deploy Backend
run: |
echo "Deploying backend..."
# Add backend deployment script here

# Deploy Frontend
- name: Deploy Frontend
run: |
echo "Deploying frontend..."
# Add frontend deployment script here
20 changes: 20 additions & 0 deletions .github/workflows/hello.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Hello World

on:
push:
branches:
- main

jobs:
say_hello:
runs-on: ubuntu-latest
steps:
- name: Print Hello World
run: echo "Hello World!"

- name: Print Date
run: date

- name: List Directory Contents
run: ls -l

48 changes: 48 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Deploy Application

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '16'

- name: Install dependencies
run: npm install

- name: Run tests
run: npm test

- name: Deploy to Production
run: npm run deploy
env:
MONGO_URI: ${{ secrets.MONGO_URI }}

- name: Notify Discord on Success
if: success() # Send notification only if the build succeeds
uses: Ilshidur/action-discord-webhook@v2
with:
webhook_url: ${{ secrets.DISCORD_WEBHOOK_URL }}
username: 'GitHub Actions'
content: 'The deployment was successful! 🎉'

- name: Notify Discord on Failure
if: failure() # Send notification only if the build fails
uses: Ilshidur/action-discord-webhook@v2
with:
webhook_url: ${{ secrets.DISCORD_WEBHOOK_URL }}
username: 'GitHub Actions'
content: 'The deployment failed! 🚨 Here is the commit that caused the issue: ${{ github.sha }}'


47 changes: 47 additions & 0 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: CI Pipeline

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Install Dependencies
run: npm install

- name: Run Tests
run: npm test

- name: Test Success
if: success()
uses: rjstone/discord-webhook-notify@v1
with:
severity: info
details: Test Succeeded!
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}

- name: Test Failure
if: failure()
uses: rjstone/discord-webhook-notify@v1
with:
severity: error
details: Test Failed!
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}

- name: Test Cancelled
if: cancelled()
uses: rjstone/discord-webhook-notify@v1
with:
severity: warn
details: Test Cancelled!
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}
27 changes: 27 additions & 0 deletions .github/workflows/secrect.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CI/CD Pipeline

on:
push:
branches:
- main
pull_request:
branches: [main]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Dependencies
run: |
npm install

- name: Build Application
run: |
npm run build

- name: Deploy Application
run: |
echo "Deploying application..."
# Add your deployment commands here
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

This repository is used for the CI/CD module of the Full stack open course

Fork the repository to complete course exercises
## Related Repositories

- **Legacy Code**: The legacy code for the phonebook app and related exercises can be found here: [Fullstack Part 11 - Legacy Code](https://github.com/tuongroth/fullstack-part11)
- **Pokedex App**: You can also check out the full-stack Pokedex app here: [Pokedex Repository](https://github.com/tuongroth/full-stack-open-pokedex)

## Commands

Expand Down
9 changes: 9 additions & 0 deletions exercise11.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Modern vs. Traditional CI Setup

When setting up Continuous Integration (CI), the choice between modern cloud-based solutions and traditional self-hosted systems depends on your project’s needs, resources, and priorities.

Modern CI solutions like GitHub Actions, CircleCI, and GitLab CI (Cloud) offer ease of use and scalability. They handle infrastructure, making them ideal for fast-paced teams focusing on development rather than system management. These tools work well with common linting, testing, and building tasks using tools like ESLint, Jest, or Webpack. However, they require reliable internet, may raise security concerns for sensitive data, and can become expensive for large-scale projects.

Traditional CI systems like Jenkins or GitLab CI (Self-Hosted) give you full control over the environment. This makes them great for secure, highly customized setups where sensitive data or offline operation is critical. However, they require more effort for setup, maintenance, and scalability, which might strain small teams.

In short, modern CI is best for flexibility and speed, while traditional CI suits teams prioritizing control and data security. Choose based on your project’s size, budget, and technical requirements.
Loading