From 05d79cc81ee64baa3693abb7f1dda8b287230eca Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Tue, 15 Oct 2024 20:08:27 +0300 Subject: [PATCH 01/60] Create hello.yml --- .github/workflows/hello.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/hello.yml diff --git a/.github/workflows/hello.yml b/.github/workflows/hello.yml new file mode 100644 index 0000000000..e6a55390a7 --- /dev/null +++ b/.github/workflows/hello.yml @@ -0,0 +1,17 @@ +name: Hello World + +on: + push: + branches: + - main + +jobs: + hello: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Say Hello + run: echo "Hello World!" From ebab5732fb10652e068118cc80522edbaaead4f8 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Tue, 15 Oct 2024 20:12:13 +0300 Subject: [PATCH 02/60] Create main.yml --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1 @@ + From 0f0ea295269bb249281527f818a5d8bdbd9f6ae1 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Tue, 15 Oct 2024 21:18:37 +0300 Subject: [PATCH 03/60] Update hello.yml --- .github/workflows/hello.yml | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/workflows/hello.yml b/.github/workflows/hello.yml index e6a55390a7..915e731122 100644 --- a/.github/workflows/hello.yml +++ b/.github/workflows/hello.yml @@ -1,17 +1,20 @@ name: Hello World -on: - push: - branches: +on: + push: + branches: - main jobs: - hello: + say_hello: runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Say Hello + - name: Print Hello World run: echo "Hello World!" + + - name: Print Date + run: date + + - name: List Directory Contents + run: ls -l + From 0a9b2e15b307f736c4eb056e28bb721e5bb43ce8 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Tue, 15 Oct 2024 21:23:39 +0300 Subject: [PATCH 04/60] Create pipeline.yml --- .github/workflows/pipeline.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/pipeline.yml diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml new file mode 100644 index 0000000000..12df73a500 --- /dev/null +++ b/.github/workflows/pipeline.yml @@ -0,0 +1,19 @@ +name: Deployment pipeline + +on: + push: + branches: + - main + +jobs: + simple_deployment_pipeline: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20' + - name: Install dependencies + run: npm install + - name: Check style + run: npm run eslint From b043615ff72f3d3977d8b627fb746cec7f34861e Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 16 Oct 2024 03:02:13 +0300 Subject: [PATCH 05/60] Update pipeline.yml --- .github/workflows/pipeline.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 12df73a500..4383053111 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -6,14 +6,8 @@ on: - main jobs: + simple_deployment_pipeline: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: '20' - - name: Install dependencies - run: npm install - - name: Check style - run: npm run eslint From 60a472a802c739d38cd1e3f75f44efe02df9843b Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 16 Oct 2024 03:05:51 +0300 Subject: [PATCH 06/60] Update pipeline.yml --- .github/workflows/pipeline.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 4383053111..f687f80030 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -6,8 +6,18 @@ on: - main jobs: - simple_deployment_pipeline: runs-on: ubuntu-20.04 steps: + # Step to check out the repository - uses: actions/checkout@v4 + + # Step to set up Node.js version 20 + - uses: actions/setup-node@v4 + with: + node-version: '20' + + # Step to install dependencies using npm + - name: Install dependencies + run: npm install +e From 346b7bdc9a1e8eec076ef3126680777070b5abe4 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 16 Oct 2024 03:32:03 +0300 Subject: [PATCH 07/60] Update pipeline.yml --- .github/workflows/pipeline.yml | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index f687f80030..656de5f155 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -8,16 +8,30 @@ on: jobs: simple_deployment_pipeline: runs-on: ubuntu-20.04 + steps: - # Step to check out the repository - - uses: actions/checkout@v4 + # Step 1: Checkout the repository + - name: Checkout code + uses: actions/checkout@v4 - # Step to set up Node.js version 20 - - uses: actions/setup-node@v4 + # Step 2: Set up Node.js environment + - name: Set up Node.js + uses: actions/setup-node@v4 with: node-version: '20' - - # Step to install dependencies using npm + + # Step 3: Install dependencies - name: Install dependencies run: npm install -e + + # Step 4: Run linting + - name: Run ESLint + run: npm run eslint + + # Step 5: Build the application + - name: Build the application + run: npm run build + + # Step 6: Run tests + - name: Run tests + run: npm test From 677b7ac5bc13bc39422dd3175824887d77c6c658 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 16 Oct 2024 03:33:48 +0300 Subject: [PATCH 08/60] Update pipeline.yml --- .github/workflows/pipeline.yml | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 656de5f155..9b5fc0bd8b 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -8,26 +8,24 @@ on: jobs: simple_deployment_pipeline: runs-on: ubuntu-20.04 - + steps: - # Step 1: Checkout the repository - - name: Checkout code - uses: actions/checkout@v4 - + # Step 1: Checkout the code + - uses: actions/checkout@v4 + # Step 2: Set up Node.js environment - - name: Set up Node.js - uses: actions/setup-node@v4 + - uses: actions/setup-node@v4 with: node-version: '20' - + # Step 3: Install dependencies - name: Install dependencies run: npm install - # Step 4: Run linting - - name: Run ESLint + # Step 4: Run ESLint (linting) + - name: Run linting run: npm run eslint - + # Step 5: Build the application - name: Build the application run: npm run build From b31a546076f3033ac1bf8be09946c6e26d472d81 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 16 Oct 2024 03:38:33 +0300 Subject: [PATCH 09/60] Update pipeline.yml --- .github/workflows/pipeline.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 9b5fc0bd8b..6fec5dd136 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -22,9 +22,7 @@ jobs: - name: Install dependencies run: npm install - # Step 4: Run ESLint (linting) - - name: Run linting - run: npm run eslint + # Step 5: Build the application - name: Build the application From 88008054d8c248d3f0b917608ec7568c5608dfd9 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 16 Oct 2024 04:07:12 +0300 Subject: [PATCH 10/60] Update pipeline.yml --- .github/workflows/pipeline.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 6fec5dd136..3276a5d70b 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -21,6 +21,10 @@ jobs: # Step 3: Install dependencies - name: Install dependencies run: npm install + # Step 4: Run ESLint (linting) + - name: Run linting + run: npm run eslint || echo "Linting failed, but continuing..." + continue-on-error: true # Allow the workflow to proceed even if linting fails From cd0b04c298963b055268d99be907c4ae324b572a Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 16 Oct 2024 14:11:16 +0300 Subject: [PATCH 11/60] Update pipeline.yml --- .github/workflows/pipeline.yml | 43 +++++++++++++++------------------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 3276a5d70b..fcf7ca260d 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -1,37 +1,32 @@ -name: Deployment pipeline +name: Deploy to Fly.io on: push: branches: - - main + - main # Adjust if you use a different branch jobs: - simple_deployment_pipeline: - runs-on: ubuntu-20.04 - + deploy: + runs-on: ubuntu-latest + steps: - # Step 1: Checkout the code - - uses: actions/checkout@v4 - - # Step 2: Set up Node.js environment - - uses: actions/setup-node@v4 + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 with: - node-version: '20' + node-version: '14' # Use your desired Node.js version - # Step 3: Install dependencies - name: Install dependencies run: npm install - # Step 4: Run ESLint (linting) - - name: Run linting - run: npm run eslint || echo "Linting failed, but continuing..." - continue-on-error: true # Allow the workflow to proceed even if linting fails - - - - # Step 5: Build the application + - name: Build the application - run: npm run build + run: npm run build # Create a production build + + - name: Deploy to Fly.io + env: + FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} # Use the secret + run: | + flyctl deploy --config fly.toml --remote-only - # Step 6: Run tests - - name: Run tests - run: npm test From 87856ad571e51d7a1b63c7cabd488d61aad70c7f Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 16 Oct 2024 14:13:28 +0300 Subject: [PATCH 12/60] Update pipeline.yml --- .github/workflows/pipeline.yml | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index fcf7ca260d..e014da1a6b 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -1,32 +1,17 @@ -name: Deploy to Fly.io - +name: Fly Deploy on: push: branches: - - main # Adjust if you use a different branch - + - master # change to main if needed jobs: deploy: + name: Deploy app runs-on: ubuntu-latest - + concurrency: deploy-group # optional: ensure only one action runs at a time steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up Node.js - uses: actions/setup-node@v2 - with: - node-version: '14' # Use your desired Node.js version - - - name: Install dependencies - run: npm install - - - name: Build the application - run: npm run build # Create a production build - - - name: Deploy to Fly.io + - uses: actions/checkout@v4 + - uses: superfly/flyctl-actions/setup-flyctl@master + - run: flyctl deploy --remote-only env: - FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} # Use the secret - run: | - flyctl deploy --config fly.toml --remote-only + FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} From cff5a22706a2789a7d29ff14c4eaaf66f6a69cb8 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 16 Oct 2024 14:29:44 +0300 Subject: [PATCH 13/60] Update pipeline.yml --- .github/workflows/pipeline.yml | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index e014da1a6b..230aa64ad1 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -1,17 +1,12 @@ -name: Fly Deploy -on: - push: - branches: - - master # change to main if needed jobs: deploy: - name: Deploy app runs-on: ubuntu-latest - concurrency: deploy-group # optional: ensure only one action runs at a time steps: - - uses: actions/checkout@v4 - - uses: superfly/flyctl-actions/setup-flyctl@master - - run: flyctl deploy --remote-only - env: - FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} - + - name: Checkout code + uses: actions/checkout@v2 + - name: Install flyctl + run: curl -L https://fly.io/install.sh | sh + - name: Add flyctl to PATH + run: echo "export PATH=$HOME/.fly/bin:$PATH" >> $GITHUB_ENV + - name: Deploy to Fly.io + run: flyctl deploy --config fly.toml --remote-only From a45ef03a2826297c57e73cdf07c4799301714f4b Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 16 Oct 2024 14:31:21 +0300 Subject: [PATCH 14/60] Update pipeline.yml --- .github/workflows/pipeline.yml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 230aa64ad1..5228d87e84 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -1,12 +1,27 @@ +name: Deploy to Fly.io + +on: + push: + branches: + - main + jobs: deploy: runs-on: ubuntu-latest + steps: + # Step 1: Checkout the code - name: Checkout code uses: actions/checkout@v2 + + # Step 2: Install flyctl - name: Install flyctl - run: curl -L https://fly.io/install.sh | sh - - name: Add flyctl to PATH - run: echo "export PATH=$HOME/.fly/bin:$PATH" >> $GITHUB_ENV + run: | + curl -L https://fly.io/install.sh | sh + echo "$HOME/.fly/bin" >> $GITHUB_PATH + + # Step 3: Deploy to Fly.io - name: Deploy to Fly.io run: flyctl deploy --config fly.toml --remote-only + env: + FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} # Ensure you have this secret set up From 06cac8430d461f7d677f01580e1d91d2fa2fb2e1 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 16 Oct 2024 14:51:05 +0300 Subject: [PATCH 15/60] Update pipeline.yml --- .github/workflows/pipeline.yml | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 5228d87e84..3d68c0e536 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -14,14 +14,30 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - # Step 2: Install flyctl + # Step 2: Set up Node.js + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '14' # Specify your desired Node.js version + env: + ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true # Allow insecure Node.js version + + # Step 3: Install flyctl - name: Install flyctl run: | curl -L https://fly.io/install.sh | sh echo "$HOME/.fly/bin" >> $GITHUB_PATH - # Step 3: Deploy to Fly.io + # Step 4: Install dependencies + - name: Install dependencies + run: npm install # Ensure dependencies are installed + + # Step 5: Build the application + - name: Build the application + run: npm run build # Adjust if your build script is different + + # Step 6: Deploy to Fly.io - name: Deploy to Fly.io run: flyctl deploy --config fly.toml --remote-only env: - FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} # Ensure you have this secret set up + FLY_API_TOKEN: 'your_fly_api_token_here' # Replace with your actual token From aa0127fa8c257ce70cd49846f06c5143c22f50b6 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 16 Oct 2024 15:47:47 +0300 Subject: [PATCH 16/60] Update pipeline.yml --- .github/workflows/pipeline.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 3d68c0e536..699228bec2 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -36,8 +36,14 @@ jobs: - name: Build the application run: npm run build # Adjust if your build script is different - # Step 6: Deploy to Fly.io + # Step 6: Set up SSH Key + - name: Set up SSH key + run: | + echo "${{ secrets.FLY_SSH_KEY }}" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + + # Step 7: Deploy to Fly.io - name: Deploy to Fly.io - run: flyctl deploy --config fly.toml --remote-only + run: flyctl deploy --app full-stack-open-pokedex-morning-wind-9529 --config fly.toml --remote-only env: - FLY_API_TOKEN: 'your_fly_api_token_here' # Replace with your actual token + FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} # Make sure to add your Fly API token as a secret as well From 2d27d0e1019ba3ca6ed6fab60cf60b5e97e9b37c Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 16 Oct 2024 15:49:13 +0300 Subject: [PATCH 17/60] Update pipeline.yml --- .github/workflows/pipeline.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 699228bec2..12c5066c6b 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -22,11 +22,7 @@ jobs: env: ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true # Allow insecure Node.js version - # Step 3: Install flyctl - - name: Install flyctl - run: | - curl -L https://fly.io/install.sh | sh - echo "$HOME/.fly/bin" >> $GITHUB_PATH + # Step 4: Install dependencies - name: Install dependencies From 7619b4bc488ceb9a9200cd6dcc320b6a980686c9 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 16 Oct 2024 18:18:28 +0300 Subject: [PATCH 18/60] Create secrect.yml --- .github/workflows/secrect.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .github/workflows/secrect.yml diff --git a/.github/workflows/secrect.yml b/.github/workflows/secrect.yml new file mode 100644 index 0000000000..ea74597561 --- /dev/null +++ b/.github/workflows/secrect.yml @@ -0,0 +1,6 @@ +- name: Set up SSH key + run: | + mkdir -p ~/.ssh + echo "${{ secrets.FLY_SSH_KEY }}" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts From 653af50f23155866a2db1155535b537e7b98c27c Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 16 Oct 2024 18:22:45 +0300 Subject: [PATCH 19/60] Update secrect.yml --- .github/workflows/secrect.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/secrect.yml b/.github/workflows/secrect.yml index ea74597561..519d5d7844 100644 --- a/.github/workflows/secrect.yml +++ b/.github/workflows/secrect.yml @@ -1,6 +1,2 @@ -- name: Set up SSH key - run: | - mkdir -p ~/.ssh - echo "${{ secrets.FLY_SSH_KEY }}" > ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa - ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts +- name: Test SSH connection to GitHub + run: ssh -T git@github.com From 2c313ddf4c507cd051797f2fa7d3758cf1b784d1 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 16 Oct 2024 19:23:41 +0300 Subject: [PATCH 20/60] Update pipeline.yml --- .github/workflows/pipeline.yml | 38 ++++++++++------------------------ 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 12c5066c6b..866ddfb469 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -1,45 +1,29 @@ -name: Deploy to Fly.io +name: CI on: push: branches: - main + pull_request: + branches: [main] + types: [opened, synchronize] + jobs: - deploy: + build: runs-on: ubuntu-latest steps: - # Step 1: Checkout the code - name: Checkout code uses: actions/checkout@v2 - # Step 2: Set up Node.js - name: Set up Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v2 with: - node-version: '14' # Specify your desired Node.js version - env: - ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true # Allow insecure Node.js version - - + node-version: '14' - # Step 4: Install dependencies - name: Install dependencies - run: npm install # Ensure dependencies are installed - - # Step 5: Build the application - - name: Build the application - run: npm run build # Adjust if your build script is different - - # Step 6: Set up SSH Key - - name: Set up SSH key - run: | - echo "${{ secrets.FLY_SSH_KEY }}" > ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa + run: npm install - # Step 7: Deploy to Fly.io - - name: Deploy to Fly.io - run: flyctl deploy --app full-stack-open-pokedex-morning-wind-9529 --config fly.toml --remote-only - env: - FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} # Make sure to add your Fly API token as a secret as well + - name: Run tests + run: npm test From e57636122b84f367f5b112db58ce7769effb37c7 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 16 Oct 2024 19:28:27 +0300 Subject: [PATCH 21/60] Update pipeline.yml --- .github/workflows/pipeline.yml | 36 +++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 866ddfb469..6ecf201ce1 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -1,29 +1,43 @@ -name: CI +name: Deploy to Fly.io on: push: branches: - main - pull_request: - branches: [main] - types: [opened, synchronize] - jobs: - build: + deploy: runs-on: ubuntu-latest steps: + # Step 1: Checkout the code - name: Checkout code uses: actions/checkout@v2 + # Step 2: Set up Node.js - name: Set up Node.js - uses: actions/setup-node@v2 + uses: actions/setup-node@v3 with: - node-version: '14' + node-version: '14' # Specify your desired Node.js version + env: + ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true # Allow insecure Node.js version + + # Step 3: Install flyctl + - name: Install flyctl + run: | + curl -L https://fly.io/install.sh | sh + echo "$HOME/.fly/bin" >> $GITHUB_PATH + # Step 4: Install dependencies - name: Install dependencies - run: npm install + run: npm install # Ensure dependencies are installed + + # Step 5: Build the application + - name: Build the application + run: npm run build # Adjust if your build script is different - - name: Run tests - run: npm test + # Step 6: Deploy to Fly.io + - name: Deploy to Fly.io + run: flyctl deploy --config fly.toml --remote-only + env: + FLY_API_TOKEN: 'FlyV1 fm2_lJPECAAAAAAAAtZjxBDvhtabGnOeYnKkC9YZ+nzPwrVodHRwczovL2FwaS5mbHkuaW8vdjGWAJLOAAvojR8Lk7lodHRwczovL2FwaS5mbHkuaW8vYWFhL3YxxDwJ4QZi0gGEASJkw1EbjyHc3aFXhMrtvcRBv3lfkQe1Hr878nxKGth1gH6vEXAS73iUJqkEAnoGdmCC2gHETi1aR4pM5kmC6EWNpXDKtjVRiLa9FvanlAzAWDQIRtfFSS3qzHcGgD0k7WDTHkr6Lv7Go4wgEz40O61x1g/WxOGQpHgbL6W9t9UgrVnuAA2SlAORgc4AQntkHwWRgqdidWlsZGVyH6J3Zx8BxCAiXna831ZFreqhqyuLg9Ce6vZfcyRK1BRx+8evsLuOfg==,fm2_lJPETi1aR4pM5kmC6EWNpXDKtjVRiLa9FvanlAzAWDQIRtfFSS3qzHcGgD0k7WDTHkr6Lv7Go4wgEz40O61x1g/WxOGQpHgbL6W9t9UgrVnuAMQQido7LzgIGGLVBfY7ZrqXZ8O5aHR0cHM6Ly9hcGkuZmx5LmlvL2FhYS92MZgEks5nD+kYzwAAAAEjCAc2F84AC5MiCpHOAAuTIgzEEID/gYiGmQAv/umWKq6JcfHEICBJzs0YXA7qWO24JH507Ol4a9cJO1DluqABmehsFW1Z' # Replace with your actual token From 46955cddd41d7514022ab6c3a253bea50b96226a Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 16 Oct 2024 19:34:57 +0300 Subject: [PATCH 22/60] Create fly.toml --- .github/workflows/fly.toml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/workflows/fly.toml diff --git a/.github/workflows/fly.toml b/.github/workflows/fly.toml new file mode 100644 index 0000000000..8d1c243698 --- /dev/null +++ b/.github/workflows/fly.toml @@ -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" From c146fc4f9ef98a8617cac7e43d10feded0781e51 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 16 Oct 2024 19:38:34 +0300 Subject: [PATCH 23/60] Create fly.yml --- .github/workflows/fly.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/workflows/fly.yml diff --git a/.github/workflows/fly.yml b/.github/workflows/fly.yml new file mode 100644 index 0000000000..de2bb050fd --- /dev/null +++ b/.github/workflows/fly.yml @@ -0,0 +1,15 @@ +app = "part3-notes-backend-part4-8" +primary_region = "sfo" + +[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" From e88d69d6167e0dd77e05cf61a10583d000b2187a Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 16 Oct 2024 19:40:37 +0300 Subject: [PATCH 24/60] Update pipeline.yml --- .github/workflows/pipeline.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 6ecf201ce1..b6c0677688 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -36,8 +36,4 @@ jobs: - name: Build the application run: npm run build # Adjust if your build script is different - # Step 6: Deploy to Fly.io - - name: Deploy to Fly.io - run: flyctl deploy --config fly.toml --remote-only - env: - FLY_API_TOKEN: 'FlyV1 fm2_lJPECAAAAAAAAtZjxBDvhtabGnOeYnKkC9YZ+nzPwrVodHRwczovL2FwaS5mbHkuaW8vdjGWAJLOAAvojR8Lk7lodHRwczovL2FwaS5mbHkuaW8vYWFhL3YxxDwJ4QZi0gGEASJkw1EbjyHc3aFXhMrtvcRBv3lfkQe1Hr878nxKGth1gH6vEXAS73iUJqkEAnoGdmCC2gHETi1aR4pM5kmC6EWNpXDKtjVRiLa9FvanlAzAWDQIRtfFSS3qzHcGgD0k7WDTHkr6Lv7Go4wgEz40O61x1g/WxOGQpHgbL6W9t9UgrVnuAA2SlAORgc4AQntkHwWRgqdidWlsZGVyH6J3Zx8BxCAiXna831ZFreqhqyuLg9Ce6vZfcyRK1BRx+8evsLuOfg==,fm2_lJPETi1aR4pM5kmC6EWNpXDKtjVRiLa9FvanlAzAWDQIRtfFSS3qzHcGgD0k7WDTHkr6Lv7Go4wgEz40O61x1g/WxOGQpHgbL6W9t9UgrVnuAMQQido7LzgIGGLVBfY7ZrqXZ8O5aHR0cHM6Ly9hcGkuZmx5LmlvL2FhYS92MZgEks5nD+kYzwAAAAEjCAc2F84AC5MiCpHOAAuTIgzEEID/gYiGmQAv/umWKq6JcfHEICBJzs0YXA7qWO24JH507Ol4a9cJO1DluqABmehsFW1Z' # Replace with your actual token + From 4918262cc8db9b176c6bd96cf243bde3d228d8db Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 16 Oct 2024 21:07:53 +0300 Subject: [PATCH 25/60] Create deployy.yaml --- .github/workflows/deployy.yaml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/deployy.yaml diff --git a/.github/workflows/deployy.yaml b/.github/workflows/deployy.yaml new file mode 100644 index 0000000000..6962950878 --- /dev/null +++ b/.github/workflows/deployy.yaml @@ -0,0 +1,27 @@ +name: CI/CD Pipeline + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + # Your other steps go here... + + deploy: + if: github.ref == 'refs/heads/main' && github.event_name == 'push' + runs-on: ubuntu-latest + + steps: + - name: Deploy application + run: flyctl deploy --config fly.toml --remote-only From a745842b8e62b3c3761e108d1bfb6cf02580b639 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 16 Oct 2024 21:44:38 +0300 Subject: [PATCH 26/60] Update secrect.yml --- .github/workflows/secrect.yml | 37 +++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/.github/workflows/secrect.yml b/.github/workflows/secrect.yml index 519d5d7844..6c9bc9d305 100644 --- a/.github/workflows/secrect.yml +++ b/.github/workflows/secrect.yml @@ -1,2 +1,35 @@ -- name: Test SSH connection to GitHub - run: ssh -T git@github.com +name: CI/CD Pipeline + +on: + push: + branches: + - main # Runs the workflow on push to the main branch + pull_request: + branches: + - main # Runs the workflow on pull requests targeting the main branch + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + # Add your build steps here + - name: Install dependencies + run: npm install + + - name: Run tests + run: npm test + + deploy: + # Only run deployment if the event is a 'push' and it's happening on the 'main' branch + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + From 2a8acc92882080e1f18302b56201b9f5a0df61bc Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 16 Oct 2024 22:17:44 +0300 Subject: [PATCH 27/60] Update secrect.yml --- .github/workflows/secrect.yml | 56 +++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/.github/workflows/secrect.yml b/.github/workflows/secrect.yml index 6c9bc9d305..1f5d4422eb 100644 --- a/.github/workflows/secrect.yml +++ b/.github/workflows/secrect.yml @@ -1,35 +1,41 @@ -name: CI/CD Pipeline +name: Deployment pipeline on: push: branches: - - main # Runs the workflow on push to the main branch - pull_request: - branches: - - main # Runs the workflow on pull requests targeting the main branch + - main jobs: - build: - runs-on: ubuntu-latest - + simple_deployment_pipeline: + runs-on: ubuntu-20.04 steps: - name: Checkout code - uses: actions/checkout@v2 - - # Add your build steps here - - name: Install dependencies - run: npm install - - - name: Run tests - run: npm test - - deploy: - # Only run deployment if the event is a 'push' and it's happening on the 'main' branch - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - runs-on: ubuntu-latest - + uses: actions/checkout@v4 + + - name: Check for #skip in commit messages + id: skip_check + run: | + if git log -1 --pretty=%B | grep -q '#skip'; then + echo "::set-output name=skip::true" + else + echo "::set-output name=skip::false" + fi + + - name: Deploy application + if: steps.skip_check.outputs.skip == 'false' + run: echo "Deploying application" + + tag_release: + needs: [simple_deployment_pipeline] + runs-on: ubuntu-20.04 steps: - name: Checkout code - uses: actions/checkout@v2 - - + uses: actions/checkout@v4 + + - name: Bump version and push tag + uses: anothrNick/github-tag-action@1.64.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + default_bump: patch + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.skip_check.outputs.skip == 'false' }} From 74b4703202489c96461d429cfdd8bc17bf489311 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 16 Oct 2024 22:20:32 +0300 Subject: [PATCH 28/60] Update secrect.yml --- .github/workflows/secrect.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/secrect.yml b/.github/workflows/secrect.yml index 1f5d4422eb..6dd0aae474 100644 --- a/.github/workflows/secrect.yml +++ b/.github/workflows/secrect.yml @@ -39,3 +39,4 @@ jobs: with: default_bump: patch if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.skip_check.outputs.skip == 'false' }} + From 72e2fcec63ac623912ff5d1a0568debfd287f0f2 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 16 Oct 2024 22:26:11 +0300 Subject: [PATCH 29/60] Update secrect.yml --- .github/workflows/secrect.yml | 41 ++++++++--------------------------- 1 file changed, 9 insertions(+), 32 deletions(-) diff --git a/.github/workflows/secrect.yml b/.github/workflows/secrect.yml index 6dd0aae474..6f2bbd0589 100644 --- a/.github/workflows/secrect.yml +++ b/.github/workflows/secrect.yml @@ -1,4 +1,4 @@ -name: Deployment pipeline +name: CI/CD Pipeline on: push: @@ -6,37 +6,14 @@ on: - main jobs: - simple_deployment_pipeline: - runs-on: ubuntu-20.04 + build: + runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Check for #skip in commit messages - id: skip_check - run: | - if git log -1 --pretty=%B | grep -q '#skip'; then - echo "::set-output name=skip::true" - else - echo "::set-output name=skip::false" - fi - + - uses: actions/checkout@v2 + - name: Install dependencies + run: npm install + - name: Run tests + run: npm test - name: Deploy application - if: steps.skip_check.outputs.skip == 'false' - run: echo "Deploying application" - - tag_release: - needs: [simple_deployment_pipeline] - runs-on: ubuntu-20.04 - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Bump version and push tag - uses: anothrNick/github-tag-action@1.64.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - default_bump: patch - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.skip_check.outputs.skip == 'false' }} + run: ./deploy.sh # Adjust based on your deployment process From d05ce957082932898a78cafa781e6dbfd9a45720 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 4 Dec 2024 15:01:06 +0200 Subject: [PATCH 30/60] Update pipeline.yml --- .github/workflows/pipeline.yml | 52 ++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index b6c0677688..c3feaef62c 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -1,4 +1,4 @@ -name: Deploy to Fly.io +name: Deployment pipeline on: push: @@ -6,34 +6,38 @@ on: - main jobs: - deploy: - runs-on: ubuntu-latest - + simple_deployment_pipeline: + runs-on: ubuntu-20.04 steps: - # Step 1: Checkout the code - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - # Step 2: Set up Node.js + # Set up Node.js (if not already set up) - name: Set up Node.js uses: actions/setup-node@v3 with: - node-version: '14' # Specify your desired Node.js version - env: - ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true # Allow insecure Node.js version - - # Step 3: Install flyctl - - name: Install flyctl - run: | - curl -L https://fly.io/install.sh | sh - echo "$HOME/.fly/bin" >> $GITHUB_PATH + node-version: '16' # Choose the appropriate Node.js version - # Step 4: Install dependencies + # Install dependencies - name: Install dependencies - run: npm install # Ensure dependencies are installed - - # Step 5: Build the application - - name: Build the application - run: npm run build # Adjust if your build script is different - - + run: npm install + + # Build the app (if needed, add a build step) + - name: Build the app + run: npm run build + + # Start the app in production mode + - name: Start the app + run: npm run start-prod & + + # Wait for the server to be available + - name: Wait for server to be ready + run: npx wait-on http://localhost:5000 + + # E2E tests + - name: E2E tests + uses: cypress-io/github-action@v5 + with: + command: npm run test:e2e + start: npm run start-prod + wait-on: http://localhost:5000 From 9baaf99caa0bd7a99999b2b4c0d4683076f13023 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 4 Dec 2024 15:07:45 +0200 Subject: [PATCH 31/60] Update pipeline.yml --- .github/workflows/pipeline.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index c3feaef62c..2985a045d3 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -22,15 +22,11 @@ jobs: - name: Install dependencies run: npm install - # Build the app (if needed, add a build step) - - name: Build the app - run: npm run build - # Start the app in production mode - name: Start the app run: npm run start-prod & - - # Wait for the server to be available + + # Wait for the server to be ready - name: Wait for server to be ready run: npx wait-on http://localhost:5000 From 5cdc51e860e230bdb2e60a764eade7e665eb64fa Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 4 Dec 2024 16:29:30 +0200 Subject: [PATCH 32/60] Create exercise11.1.md --- exercise11.1.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 exercise11.1.md diff --git a/exercise11.1.md b/exercise11.1.md new file mode 100644 index 0000000000..2b99555509 --- /dev/null +++ b/exercise11.1.md @@ -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. From ef218d73445a0786e9ce6b5fa370479ecf9351cc Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 4 Dec 2024 17:37:53 +0200 Subject: [PATCH 33/60] Update pipeline.yml --- .github/workflows/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 2985a045d3..25712b1b71 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -36,4 +36,4 @@ jobs: with: command: npm run test:e2e start: npm run start-prod - wait-on: http://localhost:5000 + wait-on: http://localhost:8081 From 814e8359a8db4647e21dcb72cd95d9640fd86410 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 4 Dec 2024 17:40:30 +0200 Subject: [PATCH 34/60] Update pipeline.yml --- .github/workflows/pipeline.yml | 61 +++++++++++++++++----------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 25712b1b71..073457d45c 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -1,39 +1,40 @@ -name: Deployment pipeline +name: Deploy to Fly.io on: push: branches: - - main + - main # Trigger deployment on push to the main branch jobs: - simple_deployment_pipeline: - runs-on: ubuntu-20.04 + build-and-deploy: + runs-on: ubuntu-latest # Use an Ubuntu environment + steps: - - name: Checkout code - uses: actions/checkout@v4 + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '16' # Set the Node.js version to use (this matches your requirement) + + - name: Install dependencies + run: npm install # Install the necessary dependencies + + - name: Build the production version + run: npm run build # Build the project (this assumes the build script is configured in package.json) + + - name: Install Flyctl + run: | + curl -L https://fly.io/install.sh | sh # Install the Fly.io CLI + + - name: Deploy to Fly.io + run: | + export FLY_API_TOKEN=${{ secrets.FLY_API_TOKEN }} # Set the Fly.io API token as an environment variable + flyctl auth token $FLY_API_TOKEN # Authenticate with Fly.io using the token + flyctl deploy # Deploy to Fly.io - # Set up Node.js (if not already set up) - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: '16' # Choose the appropriate Node.js version + - name: View logs + run: | + flyctl logs --follow # Follow logs to monitor the deployment process - # Install dependencies - - name: Install dependencies - run: npm install - - # Start the app in production mode - - name: Start the app - run: npm run start-prod & - - # Wait for the server to be ready - - name: Wait for server to be ready - run: npx wait-on http://localhost:5000 - - # E2E tests - - name: E2E tests - uses: cypress-io/github-action@v5 - with: - command: npm run test:e2e - start: npm run start-prod - wait-on: http://localhost:8081 From 0c428adae7a13a255f0b4959a40d70e698dc02fe Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 4 Dec 2024 17:49:55 +0200 Subject: [PATCH 35/60] Update pipeline.yml --- .github/workflows/pipeline.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 073457d45c..6cc0bf6784 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -28,11 +28,7 @@ jobs: run: | curl -L https://fly.io/install.sh | sh # Install the Fly.io CLI - - name: Deploy to Fly.io - run: | - export FLY_API_TOKEN=${{ secrets.FLY_API_TOKEN }} # Set the Fly.io API token as an environment variable - flyctl auth token $FLY_API_TOKEN # Authenticate with Fly.io using the token - flyctl deploy # Deploy to Fly.io + - name: View logs run: | From ec72728143e3dd2feed42677d93e9e9c562e1dc7 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 4 Dec 2024 17:51:53 +0200 Subject: [PATCH 36/60] Update pipeline.yml --- .github/workflows/pipeline.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 6cc0bf6784..b3685de020 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -30,7 +30,4 @@ jobs: - - name: View logs - run: | - flyctl logs --follow # Follow logs to monitor the deployment process - + From d9a7a3b19a34da604303e86df777f9f9d8eb55d6 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 4 Dec 2024 19:17:53 +0200 Subject: [PATCH 37/60] Update pipeline.yml --- .github/workflows/pipeline.yml | 48 ++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index b3685de020..9218010333 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -1,33 +1,35 @@ -name: Deploy to Fly.io +name: Deployment pipeline on: push: branches: - - main # Trigger deployment on push to the main branch + - main + pull_request: + branches: [main] + types: [opened, synchronize] jobs: - build-and-deploy: - runs-on: ubuntu-latest # Use an Ubuntu environment - + simple_deployment_pipeline: + runs-on: ubuntu-20.04 steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: '16' # Set the Node.js version to use (this matches your requirement) - - - name: Install dependencies - run: npm install # Install the necessary dependencies - - - name: Build the production version - run: npm run build # Build the project (this assumes the build script is configured in package.json) - - - name: Install Flyctl - run: | - curl -L https://fly.io/install.sh | sh # Install the Fly.io CLI - + - name: Checkout code + uses: actions/checkout@v4 + # Add linting, testing, and deployment steps here + + tag_release: + needs: [simple_deployment_pipeline] + runs-on: ubuntu-20.04 + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Bump version and push tag + uses: anothrNick/github-tag-action@1.64.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + default_bump: patch + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} From 50b260bc36b0a6a55c5a1b159d4968c900b1aa19 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 4 Dec 2024 19:20:26 +0200 Subject: [PATCH 38/60] Update pipeline.yml --- .github/workflows/pipeline.yml | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 9218010333..1f5d4422eb 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -4,9 +4,6 @@ on: push: branches: - main - pull_request: - branches: [main] - types: [opened, synchronize] jobs: simple_deployment_pipeline: @@ -14,7 +11,19 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - # Add linting, testing, and deployment steps here + + - name: Check for #skip in commit messages + id: skip_check + run: | + if git log -1 --pretty=%B | grep -q '#skip'; then + echo "::set-output name=skip::true" + else + echo "::set-output name=skip::false" + fi + + - name: Deploy application + if: steps.skip_check.outputs.skip == 'false' + run: echo "Deploying application" tag_release: needs: [simple_deployment_pipeline] @@ -29,7 +38,4 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: default_bump: patch - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - - - + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.skip_check.outputs.skip == 'false' }} From a855979b88e814f8b1954a685f93d83eac224d5a Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 4 Dec 2024 19:25:59 +0200 Subject: [PATCH 39/60] Update pipeline.yml --- .github/workflows/pipeline.yml | 45 +++++++++++++--------------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 1f5d4422eb..0fedcffc72 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -1,4 +1,4 @@ -name: Deployment pipeline +name: CI/CD Pipeline on: push: @@ -6,36 +6,25 @@ on: - main jobs: - simple_deployment_pipeline: - runs-on: ubuntu-20.04 + build: + runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v4 - - - name: Check for #skip in commit messages - id: skip_check - run: | - if git log -1 --pretty=%B | grep -q '#skip'; then - echo "::set-output name=skip::true" - else - echo "::set-output name=skip::false" - fi + uses: actions/checkout@v2 - - name: Deploy application - if: steps.skip_check.outputs.skip == 'false' - run: echo "Deploying application" + - name: Run build + run: npm install && npm run build - tag_release: - needs: [simple_deployment_pipeline] - runs-on: ubuntu-20.04 - steps: - - name: Checkout code - uses: actions/checkout@v4 + - name: Notify Discord of success + if: success() + uses: discord-webhook-notify@v1.0.0 + with: + webhook-url: ${{ secrets.DISCORD_WEBHOOK }} + message: "Deployment succeeded! 🎉" - - name: Bump version and push tag - uses: anothrNick/github-tag-action@1.64.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Notify Discord of failure + if: failure() + uses: discord-webhook-notify@v1.0.0 with: - default_bump: patch - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.skip_check.outputs.skip == 'false' }} + webhook-url: ${{ secrets.DISCORD_WEBHOOK }} + message: "Deployment failed! 🚨 Please check the logs for more details." From 8f5bc3a622217f8f788221d3d9f819edcc9d92b1 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 4 Dec 2024 19:27:39 +0200 Subject: [PATCH 40/60] Update pipeline.yml --- .github/workflows/pipeline.yml | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 0fedcffc72..efc51186e0 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -1,30 +1,14 @@ -name: CI/CD Pipeline +name: Periodic Health Check on: - push: - branches: - - main + schedule: + - cron: '0 0 * * *' # Runs once a day at midnight jobs: - build: + health-check: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Run build - run: npm install && npm run build - - - name: Notify Discord of success - if: success() - uses: discord-webhook-notify@v1.0.0 - with: - webhook-url: ${{ secrets.DISCORD_WEBHOOK }} - message: "Deployment succeeded! 🎉" - - - name: Notify Discord of failure - if: failure() - uses: discord-webhook-notify@v1.0.0 + - name: Check application health + uses: wzieba/health-check-action@v2 with: - webhook-url: ${{ secrets.DISCORD_WEBHOOK }} - message: "Deployment failed! 🚨 Please check the logs for more details." + url: https://your-application-url.com From bb811bdb6963796dd1655a03ef226c9de58f1e8d Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 4 Dec 2024 22:11:59 +0200 Subject: [PATCH 41/60] Update secrect.yml --- .github/workflows/secrect.yml | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/.github/workflows/secrect.yml b/.github/workflows/secrect.yml index 6f2bbd0589..da30e7c32d 100644 --- a/.github/workflows/secrect.yml +++ b/.github/workflows/secrect.yml @@ -1,19 +1,4 @@ -name: CI/CD Pipeline - on: - push: + pull_request: branches: - main - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Install dependencies - run: npm install - - name: Run tests - run: npm test - - name: Deploy application - run: ./deploy.sh # Adjust based on your deployment process - From 741ee91bdb68b775218cbb1d6d1981f5ef5c5612 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 4 Dec 2024 22:23:24 +0200 Subject: [PATCH 42/60] Update pipeline.yml --- .github/workflows/pipeline.yml | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index efc51186e0..14829ae679 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -1,14 +1,6 @@ -name: Periodic Health Check - -on: - schedule: - - cron: '0 0 * * *' # Runs once a day at midnight - -jobs: - health-check: - runs-on: ubuntu-latest - steps: - - name: Check application health - uses: wzieba/health-check-action@v2 - with: - url: https://your-application-url.com +steps: + - name: Deploy to production + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + run: | + echo "Deploying application..." + # Add your deployment commands here From 2ada9de9ac8754c5f4a042cc9d47ba40c2434341 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 4 Dec 2024 22:26:40 +0200 Subject: [PATCH 43/60] Update fly.yml --- .github/workflows/fly.yml | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/.github/workflows/fly.yml b/.github/workflows/fly.yml index de2bb050fd..17c1d66f54 100644 --- a/.github/workflows/fly.yml +++ b/.github/workflows/fly.yml @@ -1,15 +1,22 @@ -app = "part3-notes-backend-part4-8" -primary_region = "sfo" +name: CI/CD Workflow -[http_service] -auto_start_machines = true -auto_stop_machines = true -force_https = true -internal_port = 3_001 -min_machines_running = 0 -processes = [ "app" ] +on: + push: + branches: + - main + pull_request: + branches: + - main -[[vm]] -cpu_kind = "shared" -cpus = 1 -memory = "1gb" +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Deploy to production + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + run: | + echo "Deploying application..." + # Your actual deployment commands here From 542fb5ae6a64406bf0feb156c0417ad40de0a0b0 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 4 Dec 2024 22:39:53 +0200 Subject: [PATCH 44/60] Update deployy.yaml --- .github/workflows/deployy.yaml | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/.github/workflows/deployy.yaml b/.github/workflows/deployy.yaml index 6962950878..136b3b3a77 100644 --- a/.github/workflows/deployy.yaml +++ b/.github/workflows/deployy.yaml @@ -1,4 +1,4 @@ -name: CI/CD Pipeline +name: Deployment pipeline on: push: @@ -7,21 +7,6 @@ on: pull_request: branches: - main - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - # Your other steps go here... - - deploy: - if: github.ref == 'refs/heads/main' && github.event_name == 'push' - runs-on: ubuntu-latest - - steps: - - name: Deploy application - run: flyctl deploy --config fly.toml --remote-only + types: + - opened + - synchronize From 10e727277abffa525828f6fe01f7d1fa5664966e Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 4 Dec 2024 22:41:39 +0200 Subject: [PATCH 45/60] Update fly.yml --- .github/workflows/fly.yml | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/.github/workflows/fly.yml b/.github/workflows/fly.yml index 17c1d66f54..136b3b3a77 100644 --- a/.github/workflows/fly.yml +++ b/.github/workflows/fly.yml @@ -1,4 +1,4 @@ -name: CI/CD Workflow +name: Deployment pipeline on: push: @@ -7,16 +7,6 @@ on: pull_request: branches: - main - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Deploy to production - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - run: | - echo "Deploying application..." - # Your actual deployment commands here + types: + - opened + - synchronize From d8a4cb61603484a9eaba8dd68d3b1bc8314420f1 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 4 Dec 2024 22:42:36 +0200 Subject: [PATCH 46/60] Update fly.yml --- .github/workflows/fly.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.github/workflows/fly.yml b/.github/workflows/fly.yml index 136b3b3a77..d03d01e19d 100644 --- a/.github/workflows/fly.yml +++ b/.github/workflows/fly.yml @@ -10,3 +10,35 @@ on: types: - opened - synchronize + +jobs: + simple_deployment_pipeline: + runs-on: ubuntu-20.04 + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Run tests + run: | + echo "Running tests..." + # Add testing commands here + + - name: Deploy to production + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + run: | + echo "Deploying application..." + # Add your deployment commands here + + tag_release: + needs: [simple_deployment_pipeline] + runs-on: ubuntu-20.04 + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Bump version and push tag + uses: anothrNick/github-tag-action@1.64.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DEFAULT_BUMP: patch + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} From 0fe4d14a16aebd294bb306781be58c42b66adcb0 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 4 Dec 2024 22:46:57 +0200 Subject: [PATCH 47/60] Update deployy.yaml --- .github/workflows/deployy.yaml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.github/workflows/deployy.yaml b/.github/workflows/deployy.yaml index 136b3b3a77..42ad80e1d7 100644 --- a/.github/workflows/deployy.yaml +++ b/.github/workflows/deployy.yaml @@ -10,3 +10,35 @@ on: types: - opened - synchronize + +jobs: + simple_deployment_pipeline: + runs-on: ubuntu-20.04 + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Run tests + run: | + echo "Running tests..." + # Add testing commands here + + - name: Deploy to production + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, '#skip') }} + run: | + echo "Deploying application..." + # Add your deployment commands here + + tag_release: + needs: [simple_deployment_pipeline] + runs-on: ubuntu-20.04 + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Bump version and push tag + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, '#skip') }} + uses: anothrNick/github-tag-action@1.64.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DEFAULT_BUMP: patch From b6f630a28734238b9ae77ee794f6c79726aa6739 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 4 Dec 2024 22:59:43 +0200 Subject: [PATCH 48/60] Update deployy.yaml --- .github/workflows/deployy.yaml | 59 ++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/.github/workflows/deployy.yaml b/.github/workflows/deployy.yaml index 42ad80e1d7..f55f490926 100644 --- a/.github/workflows/deployy.yaml +++ b/.github/workflows/deployy.yaml @@ -1,4 +1,4 @@ -name: Deployment pipeline +name: Deployment Pipeline with Notifications on: push: @@ -12,33 +12,52 @@ on: - synchronize jobs: - simple_deployment_pipeline: + build_and_deploy: runs-on: ubuntu-20.04 steps: - - name: Checkout code - uses: actions/checkout@v3 - + - 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: | - echo "Running tests..." - # Add testing commands here - + run: npm test - name: Deploy to production - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, '#skip') }} + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} run: | echo "Deploying application..." - # Add your deployment commands here + # Deployment commands here - tag_release: - needs: [simple_deployment_pipeline] + notify: + needs: build_and_deploy runs-on: ubuntu-20.04 steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: Send Discord success notification + if: ${{ success() }} + uses: peter-evans/discord-webhook-notify@v1.2 + with: + webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }} + message: | + :tada: **Deployment Successful!** + The latest version has been successfully deployed to production. + Commit: `${{ github.sha }}` + Branch: `${{ github.ref }}` + env: + DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} - - name: Bump version and push tag - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, '#skip') }} - uses: anothrNick/github-tag-action@1.64.0 + - name: Send Discord failure notification + if: ${{ failure() }} + uses: peter-evans/discord-webhook-notify@v1.2 + with: + webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }} + message: | + :x: **Deployment Failed!** + Something went wrong during the deployment process. + Commit: `${{ github.sha }}` + Error message: `${{ job.status }}` + Please review the logs to debug the issue. env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - DEFAULT_BUMP: patch + DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} + From ffbeeef8a22a1c9b499a16dde964830da22cd96d Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 4 Dec 2024 23:01:40 +0200 Subject: [PATCH 49/60] Update deployy.yaml --- .github/workflows/deployy.yaml | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/.github/workflows/deployy.yaml b/.github/workflows/deployy.yaml index f55f490926..b860f02ed7 100644 --- a/.github/workflows/deployy.yaml +++ b/.github/workflows/deployy.yaml @@ -7,28 +7,30 @@ on: pull_request: branches: - main - types: - - opened - - synchronize jobs: build_and_deploy: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v4 + - 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..." - # Deployment commands here + # Add your deployment commands here notify: needs: build_and_deploy @@ -36,28 +38,23 @@ jobs: steps: - name: Send Discord success notification if: ${{ success() }} - uses: peter-evans/discord-webhook-notify@v1.2 + uses: Ilshidur/action-discord@2.0.2 with: - webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }} + webhook: ${{ secrets.DISCORD_WEBHOOK_URL }} message: | :tada: **Deployment Successful!** The latest version has been successfully deployed to production. Commit: `${{ github.sha }}` - Branch: `${{ github.ref }}` - env: - DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} + Branch: `${{ github.ref_name }}` - name: Send Discord failure notification if: ${{ failure() }} - uses: peter-evans/discord-webhook-notify@v1.2 + uses: Ilshidur/action-discord@2.0.2 with: - webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }} + webhook: ${{ secrets.DISCORD_WEBHOOK_URL }} message: | :x: **Deployment Failed!** Something went wrong during the deployment process. Commit: `${{ github.sha }}` - Error message: `${{ job.status }}` - Please review the logs to debug the issue. - env: - DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} - + Branch: `${{ github.ref_name }}` + Please review the logs for more details. From ef3372dcd83671632ba4708b3f0f5742aa083c9f Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 4 Dec 2024 23:07:01 +0200 Subject: [PATCH 50/60] Rename deployy.yaml to deployy.yaml From 3c23a63cc7b9bc77198cce64401a2d112fb6bcaa Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 4 Dec 2024 23:15:24 +0200 Subject: [PATCH 51/60] Update secrect.yml --- .github/workflows/secrect.yml | 48 ++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/.github/workflows/secrect.yml b/.github/workflows/secrect.yml index da30e7c32d..4c158f1cce 100644 --- a/.github/workflows/secrect.yml +++ b/.github/workflows/secrect.yml @@ -1,4 +1,50 @@ +name: CI/CD Pipeline for My App + on: - pull_request: + push: branches: - main + pull_request: + branches: [main] + +jobs: + test_and_lint: + runs-on: ubuntu-20.04 + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js for frontend + uses: actions/setup-node@v4 + with: + node-version: '16' + + - name: Install frontend dependencies + run: | + cd frontend + npm install + + - name: Run frontend tests + run: | + cd frontend + npm test + + - name: Setup Node.js for backend + uses: actions/setup-node@v4 + with: + node-version: '16' + + - name: Install backend dependencies + run: npm install + + - name: Run backend tests + run: npm test + + deploy: + needs: test_and_lint + runs-on: ubuntu-20.04 + steps: + - name: Deploy application + run: | + echo "Deploying application..." + # Add your deployment scripts here From 5eb29e099b3a6efa625b7f745d385c6a94e6a1e7 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 4 Dec 2024 23:16:58 +0200 Subject: [PATCH 52/60] Update secrect.yml --- .github/workflows/secrect.yml | 41 ++++++++++------------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/.github/workflows/secrect.yml b/.github/workflows/secrect.yml index 4c158f1cce..b4a196fc2d 100644 --- a/.github/workflows/secrect.yml +++ b/.github/workflows/secrect.yml @@ -1,4 +1,4 @@ -name: CI/CD Pipeline for My App +name: CI/CD Pipeline on: push: @@ -9,42 +9,25 @@ on: jobs: test_and_lint: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: Setup Node.js for frontend - uses: actions/setup-node@v4 - with: - node-version: '16' - - - name: Install frontend dependencies + - name: Frontend - Install and Test + working-directory: ./frontend run: | - cd frontend npm install + npm test - - name: Run frontend tests + - name: Backend - Install and Test + working-directory: ./ run: | - cd frontend + npm install npm test - - name: Setup Node.js for backend - uses: actions/setup-node@v4 - with: - node-version: '16' - - - name: Install backend dependencies - run: npm install - - - name: Run backend tests - run: npm test - deploy: needs: test_and_lint - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - - name: Deploy application - run: | - echo "Deploying application..." - # Add your deployment scripts here + - name: Deploy Application + run: echo "Deployment Step (add your script)" From 769649e87ac3f14bd394ce6fff96e400ccddae31 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 4 Dec 2024 23:21:05 +0200 Subject: [PATCH 53/60] Update secrect.yml --- .github/workflows/secrect.yml | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/.github/workflows/secrect.yml b/.github/workflows/secrect.yml index b4a196fc2d..63048fadf2 100644 --- a/.github/workflows/secrect.yml +++ b/.github/workflows/secrect.yml @@ -8,26 +8,20 @@ on: branches: [main] jobs: - test_and_lint: + deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Frontend - Install and Test - working-directory: ./frontend + - name: Install Dependencies run: | npm install - npm test - - name: Backend - Install and Test - working-directory: ./ + - name: Build Application run: | - npm install - npm test + npm run build - deploy: - needs: test_and_lint - runs-on: ubuntu-latest - steps: - name: Deploy Application - run: echo "Deployment Step (add your script)" + run: | + echo "Deploying application..." + # Add your deployment commands here From dda7e353cc290d179354ffbf1d12a2724d619a8b Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Wed, 4 Dec 2024 23:29:06 +0200 Subject: [PATCH 54/60] Update fly.yml --- .github/workflows/fly.yml | 72 ++++++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 28 deletions(-) diff --git a/.github/workflows/fly.yml b/.github/workflows/fly.yml index d03d01e19d..dccb01a3d8 100644 --- a/.github/workflows/fly.yml +++ b/.github/workflows/fly.yml @@ -1,44 +1,60 @@ -name: Deployment pipeline +name: CI/CD Pipeline on: push: branches: - main pull_request: - branches: - - main - types: - - opened - - synchronize + branches: [main] jobs: - simple_deployment_pipeline: - runs-on: ubuntu-20.04 + test_and_lint: + runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - name: Run tests + # Backend Tests + - name: Set up Node.js for backend + uses: actions/setup-node@v3 + with: + node-version: '16' + - name: Install backend dependencies run: | - echo "Running tests..." - # Add testing commands here + cd backend + npm install + - name: Run backend tests + run: | + cd backend + npm test - - name: Deploy to production - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + # 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: | - echo "Deploying application..." - # Add your deployment commands here + cd frontend + npm test - tag_release: - needs: [simple_deployment_pipeline] - runs-on: ubuntu-20.04 + deploy: + needs: [test_and_lint] + runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - name: Bump version and push tag - uses: anothrNick/github-tag-action@1.64.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - DEFAULT_BUMP: patch - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + # 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 From 350b6ca6e836aa26184b1656dea8a6d0a9404851 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Fri, 6 Dec 2024 09:11:09 +0200 Subject: [PATCH 55/60] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index d8424fe5c6..2bebc625b9 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ This repository is used for the CI/CD module of the Full stack open course Fork the repository to complete course exercises +https://github.com/tuongroth/fullstack-part11.git + ## Commands Start by running `npm install` inside the project folder From e192e3ef63336b71d2835c80d0db5d1a87900645 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Fri, 6 Dec 2024 09:33:06 +0200 Subject: [PATCH 56/60] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2bebc625b9..c22face70c 100644 --- a/README.md +++ b/README.md @@ -2,9 +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 -https://github.com/tuongroth/fullstack-part11.git +- **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 From 71cc18ab855df9b380abe7f52f270d67babf9162 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Fri, 6 Dec 2024 10:35:21 +0200 Subject: [PATCH 57/60] Update main.yml --- .github/workflows/main.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8b13789179..234421b937 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1 +1,36 @@ +name: Periodic Health Check + +on: + push: + branches: + - main # Triggered on push to main branch + schedule: + - cron: '0 0 * * *' # Scheduled trigger to run every day at midnight UTC + +jobs: + health-check: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Ping deployed service URL + uses: jtalk/url-health-check-action@v4 + with: + # The URLs you want to health check + url: https://your-deployed-service.com + # Whether to follow redirects (optional) + follow-redirect: false + # Maximum retry attempts + max-attempts: 3 + # Delay between retries + retry-delay: 5s + # Retry all errors, including 404 + retry-all: false + # Optional cookie for the request + cookie: "token=your-token" + # Optional Basic Authentication + basic-auth: "your-username:your-password" + From d8afb0de0512ebd56cdd7747e5d3832cfdcd6d1e Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Fri, 6 Dec 2024 11:22:09 +0200 Subject: [PATCH 58/60] Update main.yml --- .github/workflows/main.yml | 64 ++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 26 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 234421b937..53b15dde49 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,36 +1,48 @@ - -name: Periodic Health Check +name: Deploy Application on: push: branches: - - main # Triggered on push to main branch - schedule: - - cron: '0 0 * * *' # Scheduled trigger to run every day at midnight UTC + - main jobs: - health-check: + build: runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Ping deployed service URL - uses: jtalk/url-health-check-action@v4 - with: - # The URLs you want to health check - url: https://your-deployed-service.com - # Whether to follow redirects (optional) - follow-redirect: false - # Maximum retry attempts - max-attempts: 3 - # Delay between retries - retry-delay: 5s - # Retry all errors, including 404 - retry-all: false - # Optional cookie for the request - cookie: "token=your-token" - # Optional Basic Authentication - basic-auth: "your-username:your-password" + - 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 }}' + From de2a0f72267940cae5cb9919b61bc9b6b56db978 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Fri, 6 Dec 2024 15:44:34 +0200 Subject: [PATCH 59/60] Update pipeline.yml --- .github/workflows/pipeline.yml | 53 ++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 14829ae679..683802cebd 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -1,6 +1,47 @@ -steps: - - name: Deploy to production - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - run: | - echo "Deploying application..." - # Add your deployment commands here +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 }} From cffb7f4d00aa3fb6b3ffa8c9eb95b7afbb442677 Mon Sep 17 00:00:00 2001 From: tuongroth <44430600+tuongroth@users.noreply.github.com> Date: Fri, 6 Dec 2024 15:54:56 +0200 Subject: [PATCH 60/60] Update PokemonPage.jest.spec.jsx --- test/PokemonPage.jest.spec.jsx | 115 +++++++++++++++++---------------- 1 file changed, 61 insertions(+), 54 deletions(-) diff --git a/test/PokemonPage.jest.spec.jsx b/test/PokemonPage.jest.spec.jsx index 5a2b900545..210a1e9799 100644 --- a/test/PokemonPage.jest.spec.jsx +++ b/test/PokemonPage.jest.spec.jsx @@ -1,13 +1,13 @@ -import React from 'react' -import { render, screen } from '@testing-library/react' -import axiosMock from 'axios' -import { act } from 'react-dom/test-utils' -import '@testing-library/jest-dom' -import PokemonPage from '../src/PokemonPage' +import React from 'react'; +import { render, screen } from '@testing-library/react'; +import axiosMock from 'axios'; +import { act } from 'react-dom/test-utils'; +import '@testing-library/jest-dom'; +import PokemonPage from '../src/PokemonPage'; -import { MemoryRouter } from 'react-router-dom' +import { MemoryRouter } from 'react-router-dom'; -jest.mock('axios') +jest.mock('axios'); const pokemonList = { id: 133, @@ -15,19 +15,19 @@ const pokemonList = { { ability: { name: 'anticipation', - url: 'https://pokeapi.co/api/v2/ability/107/' + url: 'https://pokeapi.co/api/v2/ability/107/', }, is_hidden: true, - slot: 3 + slot: 3, }, { ability: { name: 'adaptability', - url: 'https://pokeapi.co/api/v2/ability/91/' + url: 'https://pokeapi.co/api/v2/ability/91/', }, is_hidden: false, - slot: 2 - } + slot: 2, + }, ], name: 'eevee', stats: [ @@ -36,99 +36,106 @@ const pokemonList = { effort: 0, stat: { name: 'attack', - url: 'https://pokeapi.co/api/v2/stat/2/' - } + url: 'https://pokeapi.co/api/v2/stat/2/', + }, }, { base_stat: 55, effort: 0, stat: { name: 'hp', - url: 'https://pokeapi.co/api/v2/stat/1/' - } - } + url: 'https://pokeapi.co/api/v2/stat/1/', + }, + }, ], types: [ { slot: 1, type: { name: 'normal', - url: 'https://pokeapi.co/api/v2/type/1/' - } - } + url: 'https://pokeapi.co/api/v2/type/1/', + }, + }, ], - sprites: { front_default: 'URL' } -} + sprites: { front_default: 'URL' }, +}; const previous = { url: 'https://pokeapi.co/api/v2/pokemon/132/', name: 'ditto', - id: 132 -} + id: 132, +}; const next = { url: 'https://pokeapi.co/api/v2/pokemon/134/', name: 'vaporeon', - id: 134 -} + id: 134, +}; describe('', () => { + beforeEach(() => { + jest.clearAllMocks(); // Ensure no previous mocks interfere. + }); + it('should render abilities', async () => { - axiosMock.get.mockResolvedValueOnce({ data: pokemonList }) + axiosMock.get.mockResolvedValueOnce({ data: pokemonList }); await act(async () => { render( , - ) - }) + ); + }); - expect(screen.getByText('adaptability')).toBeVisible() - expect(screen.getByText('anticipation')).toBeVisible() - }) + expect(screen.getByText('adaptability')).toBeVisible(); + expect(screen.getByText('anticipation')).toBeVisible(); + }); it('should render stats', async () => { - axiosMock.get.mockResolvedValueOnce({ data: pokemonList }) + axiosMock.get.mockResolvedValueOnce({ data: pokemonList }); await act(async () => { render( , - ) - }) + ); + }); - expect(screen.getByTestId('stats')).toHaveTextContent('hp55attack55') - }) + expect(screen.getByTestId('stats')).toHaveTextContent('hp55attack55'); + }); - it('should render previous and next urls if they exist', async () => { - axiosMock.get.mockResolvedValueOnce({ data: pokemonList }) + it('should render previous and next URLs if they exist', async () => { + axiosMock.get.mockResolvedValueOnce({ data: pokemonList }); await act(async () => { render( - + , - ) - }) + ); + }); + + const previousLink = screen.getByText('Previous'); + const nextLink = screen.getByText('Next'); - expect(screen.getByText('Previous')).toHaveAttribute('href', '/pokemon/ditto') - expect(screen.getByText('Next')).toHaveAttribute('href', '/pokemon/vaporeon') - }) + expect(previousLink).toHaveAttribute('href', '/pokemon/ditto'); + expect(nextLink).toHaveAttribute('href', '/pokemon/vaporeon'); + }); - it('should not render previous and next urls if none exist', async () => { - axiosMock.get.mockResolvedValueOnce({ data: pokemonList }) + it('should not render previous and next URLs if none exist', async () => { + axiosMock.get.mockResolvedValueOnce({ data: pokemonList }); await act(async () => { render( , - ) - }) + ); + }); - expect(screen.queryByText('Previous')).toBeNull() - expect(screen.queryByText('Next')).toBeNull() - }) -}) + expect(screen.queryByText('Previous')).toBeNull(); + expect(screen.queryByText('Next')).toBeNull(); + }); +});