Skip to main content

Command Palette

Search for a command to run...

[TIL] What I Newly Learned (feat. CI/CD)

05/11/23

Updated
[TIL] What I Newly Learned (feat. CI/CD)

๐Ÿ“Œ What I newly learned

- git stash

: Temporary storage for changes

- git rebase

: Rearranges, combines, or eliminates commits in one branch by applying them to another branch. Typically used to clean up or combine commit history between branches.

- Using pm2

- pm2 restart [idNumber]: Restart the currently running pm2 service. - pm2 list: List the services managed by pm2. - pm2 delete [pid number]: Stop the currently running pm2 service. - pm2 log: Display the logs of the executed services. It can also display error messages, making it useful for debugging. - pm2 logs --lines [number]: Output the last [number] of logs in chronological order.

- Github Action -> CI/CD

  • Encountered an error because the .env file was not being read.

  • To use dotenv in Github Action, you need to add the environment variables to the repository.

  • Repository > Settings > Security > Actions > New Repository Secret button

  • Add all the environment variables used in the workflow.

  • These variables can be accessed in the action workflow using syntax like echo "SECRET_KEY=${{ secrets.SECRET_KEY }}" >> .env.

  • Modify the .yml file accordingly.

name: Node.js CI

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

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3
    - name: Setup Node.js 16.x
      uses: actions/setup-node@v3
      with:
        node-version: 16.x
        cache: 'npm'
    - name: Load env file
      run: |
        touch .env
        echo "SECRET_KEY=${{ secrets.SECRET_KEY }}" >> .env
        echo "REFRESH_EXPIRES=${{ secrets.REFRESH_EXPIRES }}" >> .env
        echo "ACCESS_EXPIRES=${{ secrets.ACCESS_EXPIRES }}" >> .env
        echo "BCRYPT_SALT_ROUNDS=${{ secrets.BCRYPT_SALT_ROUNDS }}" >> .env
        echo "HOST_PORT=${{ secrets.HOST_PORT }}" >> .env
        echo "DB_TEST_NAME=${{ secrets.DB_TEST_NAME }}" >> .env
        echo "DB_USER=${{ secrets.DB_USER }}" >> .env
        echo "DB_PASSWORD=${{ secrets.DB_PASSWORD }}" >> .env
        echo "DB_NAME=${{ secrets.DB_NAME }}" >> .env
        echo "DB_HOST=${{ secrets.DB_HOST }}" >> .env
        echo

 "DB_DIALECT=${{ secrets.DB_DIALECT }}" >> .env
        echo "NODEMAILER_USER=${{ secrets.NODEMAILER_USER }}" >> .env
        echo "NODEMAILER_PASS=${{ secrets.NODEMAILER_PASS }}" >> .env
        echo "NODEMAILER_SERVICE=${{ secrets.NODEMAILER_SERVICE }}" >> .env
    - name: Install Dependencies
      run: npm ci
    - run: npm test
  • During this process, I encountered the following error multiple times, which was caused by not creating the test database. To resolve it, create the test database with npx sequelize db:create --env test!

  • All the tests passed, but I got this error. It seems like the address is already in use because the server is running with pm2. How do I resolve this...? It will be my next challenge...

๐Ÿ“Œ What to learn next

  • Resolve the error in the previous Github Action and complete the CI/CD setup.

More from this blog

[์ฝ”ํ…Œ] ๊ทธ๋ฆฌ๋”” ๋ฌธ์ œ - ๋ฌด์ง€์˜ ๋จน๋ฐฉ ๋ผ์ด๋ธŒ

https://school.programmers.co.kr/learn/courses/30/lessons/42891 ํšจ์œจ์„ฑ ํ…Œ์ŠคํŠธ์— ์‹ ๊ฒฝ์จ์•ผ ํ•˜๋Š” ๋ฌธ์ œ ์šฐ์„ ์ˆœ์œ„ ํ๋ฅผ ํ™œ์šฉํ•ด์„œ ๋จน๋Š” ์‹œ๊ฐ„์ด ์งง์€ ์Œ์‹๋ถ€ํ„ฐ ํ์—์„œ ๋นผ๊ธฐ import heapq # ์šฐ์„ ์ˆœ์œ„ํ ํ™œ์šฉ: food_time์ด ์งง์€ ์Œ์‹๋ถ€ํ„ฐ ์‚ญ์ œ def solution(food_times, k): if sum(food_times) <= k: return -1 ...

Apr 4, 2024
[์ฝ”ํ…Œ] ๊ทธ๋ฆฌ๋”” ๋ฌธ์ œ - ๋ฌด์ง€์˜ ๋จน๋ฐฉ ๋ผ์ด๋ธŒ

[์ฝ”ํ…Œ] ์—ฌํ–‰๊ฒฝ๋กœ

๐Ÿ’ก [์ถœ๋ฐœ์ง€, ๋„์ฐฉ์ง€] ํ˜•ํƒœ๋กœ ์ฃผ์–ด์ง„ ๋น„ํ–‰๊ธฐ ํ‹ฐ์ผ“์„ ํ†ตํ•ด ๋ชจ๋“  ํ‹ฐ์ผ“์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๊ฒฝ์šฐ์˜ ๊ณตํ•ญ์„ ๋ฐฉ๋ฌธ ์ˆœ์„œ ๊ตฌํ•˜๊ธฐ (๋‹จ, ์—ฌ๋Ÿฌ ๊ณตํ•ญ์„ ๋ฐฉ๋ฌธํ•  ์ˆ˜ ์žˆ๋Š” ๊ฒฝ์šฐ ์•ŒํŒŒ๋ฒณ์ด ๋น ๋ฅธ ๊ณตํ•ญ๋ถ€ํ„ฐ ๋ฐฉ๋ฌธํ•œ๋‹ค.) ํ‹€๋ ธ๋˜ ์ฝ”๋“œ from collections import defaultdict def dfs(graph, route, depart): if graph[depart]: connected = graph[depart][0] ...

Feb 26, 2024
[์ฝ”ํ…Œ] ์—ฌํ–‰๊ฒฝ๋กœ

siwon.log

161 posts