HomeAboutMeBlogGuest
© 2025 Sejin Cha. All rights reserved.
Built with Next.js, deployed on Vercel
📝
GitHub Action을 활용한 자동 크롤러 웹 페이지 만들기
/
📝
1. hello github action
📝

1. hello github action

구체적인 내용은 뒤에 언급하도록 하고, 실습으로 들어가겠습니다. github에 로그인 한 후 Start a Project를 눌러주세요.
notion image
 
repo를 새로 만들도록 하겠습니다. Add a README file은 선택해주세요.
notion image
 
Action 탭을 선택하고 set up a workflow yourself를 클릭해주세요. 하단에 다른 workflow를 선택할 수 있지만 이번 시간에는 가장 기본적인 템플릿으로 시작해보도록 하겠습니다.
 
notion image
 
아래 주어지는 코드가 기본 코드입니다.
notion image
 
기본 템플릿 코드입니다. 주석은 뒤에서 하나씩 설명을 해드릴 예정입니다.
# This is a basic workflow to help you get started with Actions name: CI # Controls when the action will run. on: # Triggers the workflow on push or pull request events but only for the main branch push: branches: [ main ] pull_request: branches: [ main ] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: # This workflow contains a single job called "build" build: # 실행되는 OS, Window와 Mac OS도 제공합니다. runs-on: ubuntu-latest # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 # Runs a single command using the runners shell - name: Run a one-line script run: echo Hello, world! # Runs a set of commands using the runners shell - name: Run a multi-line script run: | echo Add other actions to build, echo test, and deploy your project.
 
우측에 보면 Document도 제공하고 있습니다.
notion image
 
처음으로 테스트해볼 코드입니다. 모두 지우시고 아래 코드를 입력해주세요.
name: helloGithubAction on: [push] jobs: build: runs-on: ubuntu-latest steps: # run 뒤에는 실제 작동하는 코드를 넣어야 합니다. - name: hello world 출력!! run: echo Hello, world! - name: 디렉토리 출력!! run: ls -al - name: 파이썬 버전 출력!! run: python -V
 
그대로 commit하겠습니다. 로컬에서 CLI 창에서 pull받아 push 할 수도 있지만, 우리는 가능하면 웹 상에서 모두 해결하도록 하겠습니다.
notion image
 
 
파일 생성이 완료되었습니다.
notion image
 
최상위 폴더로 들어와 Create new file을 클릭해주세요.
 
notion image
 
test.py라는 파일을 하나 생성하도록 하겠습니다.
notion image
 
 
아래로 스크롤을 내리셔서 commit 해주세요.
 
notion image
 
Actions 탭으로 들어가시면 주황색표시가 곧 아래처럼 초록색 체크로 바뀌면서 모든 Action이 다 돌아간 것을 볼 수 있습니다. hello github action test1 을 클릭해주세요. 여러분이 만드신 파일의 commit title에 따라 이 이름이 바뀔 수 있습니다.
 
notion image
notion image
 
빌드를 클릭해주세요.
notion image
 
 
우리가 적어놓은 job이 순서대로 실행된 것을 볼 수 있습니다.
notion image
 
모든 build를 확인해봅시다.
 
notion image
 
 
다시 코드로 돌아와 Python 실행봅시다. 팬 버튼을 클릭해서 수정해주세요.
 
notion image
 
 
name: helloGithubAction on: [push] jobs: build: runs-on: ubuntu-latest steps: # run 뒤에는 실제 작동하는 코드를 넣어야 합니다. - name: hello world 출력!! run: echo Hello, world! - name: 디렉토리 출력!! run: ls -al - name: 파이썬 버전 출력!! run: python -V - name: 파이썬 파일 실행!! run: python 'test.py'
 
commit을 해주세요.
notion image
 
애러가 난 것을 알 수 있습니다. 해당 파일을 Actions에서 못찾고 있는 것인데요.
notion image
 
아래와 같이 uses 코드를 삽입해주시면 정상적으로 실행이 됩니다.
name: helloGithubAction on: [push] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Run Python run: python test.py
 
hello world가 출력되셨나요? 이제 본격적으로 github actions를 다뤄보도록 하겠습니다.
  • 실행시간이 너무 긴 파일을 실행했다면 아래처럼 해당 jobs를 취소하는 것도 가능합니다.
    • notion image