본문 바로가기
반응형

개발/Git, GitHub72

깃허브 - 개인 토큰 발급 받기 (Personal access tokens) Git / GitHub 전체 링크 참고 - RESTful API로 파일 읽기 - fetch / pull 할 때 ID, Password 자동 입력하기 토큰을 발급받으면 깃허브의 RESTful API나 CLI 사용시 비밀번호를 대체할 수 있다. 깃허브 웹사이트에서 Settings로 이동한다. 왼쪽 하단의 Developer settings를 클릭한다. [Personal access tokens] → [Tokens (classic)] → Generate new token에서 classic을 클릭한다. 토큰에 대한 정보를 입력하고 만기일을 설정한다. 만기일은 무제한을 설정할 수 있지만, 보안에 유의해야 한다. 토큰 권한에 대한 필요한 scopes를 선택할 수 있다. 발급 받은 토큰은 복사해서 로컬에 저장한다. 만.. 2024. 3. 1.
깃허브 머메이드 - 클래스 다이어그램 그리기 (Draw Class Diagram using GitHub Mermaid) Git / GitHub 전체 링크 참고 - https://mermaid.js.org/syntax/classDiagram.html - 클래스 다이어그램 깃허브 머메이드를 이용해 클래스 다이어그램을 그려보자. 비주얼 스튜디오 코드에서 mermaid를 검색하면 Preview 플러그인을 다운 받을 수 있다. 플러그인을 설치하면 아래와 같이 클래스 다이어그램을 미리볼 수 있다. 클래스 다이어그램 화살표 머메이드에서 아래 코드를 작성해보자. ```mermaid --- title: Class Diagram example --- classDiagram classA Navigable Association (A에는 B가 있다. A has B) Realization / Implementation (실체화, 인터페이스 구현).. 2024. 1. 27.
깃허브 액션 - 로또 번호 수집해서 json으로 저장하기 (리포지토리 파일 수정하기) Node JS 전체 링크 Git / GitHub 전체 링크 참고 - Schedule로 반복 작업하기 - RESTful API로 파일 쓰기 깃허브 액션으로 로또 번호를 수집해서 깃허브 리포지토리에 저장해 보자. 참고로 1103회 로또 번호는 다음과 같다. 로또 번호 API 사용하기 동행복권에서는 회차별 로또 번호에 대한 정보를 주는 API를 제공한다. drwNo에 숫자를 넣으면 해당 회차별 번호를 알 수 있다. https://www.dhlottery.co.kr/common.do?method=getLottoNumber&drwNo=${drwNo} Node JS에서 아래 코드를 실행해 보자. const axios = require("axios"); const getLottoNumber = async (drwNo.. 2024. 1. 23.
Git Bash - 윈도우 사용 중인 포트 강제 종료하기 Git / GitHub 전체 링크 리액트를 종료했음에도 새로 시작할 경우 아래와 같이 현재 포트가 사용 중인 경우가 있다. $ npm run start > react-material@0.1.0 start > react-scripts start ... Something is already running on port 3000. 이런 경우 강제로 사용 중인 포트를 종료해 보자. Git Bash에서 netstat -ano | grep [Port Number]를 입력해보자. $ netstat -ano | grep 3000 TCP 0.0.0.0:3000 0.0.0.0:0 LISTENING 32692 TCP 127.0.0.1:3000 127.0.0.1:14296 ESTABLISHED 32692 TCP 127.0.0.. 2024. 1. 14.
깃허브 액션 - Schedule로 반복 작업하기 Git / GitHub 전체 링크 참고 - https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule 아래의 yml을 repo의 .github/workflow에 추가해 보자. (just-10-minutes.yml) name: Every 10 Minutes schedule on: schedule: - cron: '*/10 * * * *' jobs: ten_minutes_schedule_job: runs-on: ubuntu-latest steps: - name: Display current time run: | echo "Current Time" echo "UTC : $(date +"%Y-%m-%dT%H:%.. 2024. 1. 7.
깃허브 액션 - Push 될 때 메일 보내기 (Send Email using GitHub Actions) Git / GitHub 전체 링크 참고 - Node JS + jest를 GitHub Actions로 실행하기 - nodemailer로 구글, 네이버, 다음 카카오 메일 보내기 - 메일 알림 설정하기 깃허브 액션을 이용하여 repo에 push될 때마다 메일을 보내보자. 먼저 링크를 참고하여 아래의 sendEmail.js를 repository에 저장하자. 참고로 gmail의 경우 from을 설정할 필요가 없다. const nodemailer = require('nodemailer'); async function sendEmail() { const transporter = nodemailer.createTransport({ service: "gmail", secure: false, auth: { user: p.. 2023. 12. 16.
깃허브 - RESTful API로 파일 이름 변경하기 (Renaming files) Git / GitHub 전체 링크 참고 - RESTful API로 파일 읽기 - RESTful API로 파일 쓰기 - RESTful API로 파일 삭제하기 이름을 변경하는 API는 지원하지 않는 것으로 보인다. 따라서 파일을 읽어서(GET) 다른 이름으로 그대로 쓰고(PUT), 원본 파일을 지운다(DELETE). 전체 코드는 다음과 같다. (auto-test 저장소의 test/apitest.txt 파일을 test/apitest_new.txt로 변경) let myKey = "..."; const { Octokit } = require("@octokit/rest"); const octokit = new Octokit({ auth: myKey, }); async function renameFile() { co.. 2023. 10. 16.
깃허브 - RESTful API로 파일 삭제하기 (Delete GitHub Files with DELETE) Git / GitHub 전체 링크 참고 - RESTful API로 파일의 SHA 구하기 - RESTful API로 파일 쓰기 - RESTful API로 파일 이름 변경하기 파일을 삭제하기 위해서는 sha와 DELETE가 필요하다. const getSHAforMainFile = async (octokit) => { const result = await octokit.request( `GET /repos/bloodstrawberry/${repo}/contents/${path}`, { owner: "bloodstrawberry", repo: `${repo}`, path: `${path}`, } ); return result.data.sha; }; const handleDelete = async () => { .. 2023. 9. 6.
깃허브 - 메일 알림 설정하기 (Settings for Email Notifications) Git / GitHub 전체 링크 참고 - 깃허브 코드 소유자 정보 - 파일 편집 후 메일 알림이 가도록 수정하기 - Push 될 때 메일 보내기 - CODEOWNERS - Email notofications - Watch CODEOWNERS 깃허브에서 제공하는 코드 소유자 정보 예시는 아래와 같다. # This is a comment. # Each line is a file pattern followed by one or more owners. # These owners will be the default owners for everything in # the repo. Unless a later match takes precedence, # @global-owner1 and @global-owner2.. 2023. 9. 2.
반응형