나의 길

github actions 알아보기 본문

git&github

github actions 알아보기

MoonjuLee 2023. 9. 23. 23:34

github repository에 Actions라는 탭을 알아보려고 한다.

Action tab을 클릭하면 위의 이미지와 같이 workflow를 만들 수 있습니다.

 

만약 제안된 workflow를 그냥 사용하게 되면 Hello world 가 찍히는 Action을 설정한 yml파일이 만들어지므로 해당 글에서는 실질적인 사용 방법을 위해 set up a workflow yourself를 클릭해준다.

 

그럼 위와 같이 우리가 모든 것을 설정 해야하는 다소 부담스러운 main.yml이 생성된다.

빈 파일로 하나씩 채워가기 보다는 글의 맨 밑에 있는 공식 문서 안에 예시를 가져와 같이 보는게 좋다고 생각해 첨부하여 한 줄씩 같이 살펴보도록 하자.

name: learn-github-actions
run-name: ${{ github.actor }} is learning GitHub Actions
on: [push]
jobs:
  check-bats-version:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v3
        with:
          node-version: '14'
      - run: npm install -g bats
      - run: bats -v
  1. name 워크플로우의 이름으로 생략 가능하며, 생략하면 파일의 이름으로 대신 사용됩니다.
  2. run-name 생성된 워크플로우 실행 이름으로 생략이 가능하고 위에서는 컨텍스트와 표현식을 사용하여 초기 워크플로우의 실행자의 사용자 이름입니다. 워크플로우가 다시 실행되는 경우 이 값은 달라질 수 있습니다.
  3. on 트리거를 지정하고 위에서는 push 이벤트가 발생할 때 마다 실행된다.
  4. jobs 워크플로우의 작업을 그룹화한다.
  5. check-bats-version 하나의 작업 이름.
  6. runs-on: ubuntu-latest → 작업이 실행되는 운영체제 실행(ubuntu, mac, window 가능)
  7. steps → 작업의 단계들 그룹화
  8. uses : actions/checkout@v4 → 작업을 모두 다 작성하기 힘드니 다른 사람이 작성한 작업을 사용하기 위해 uses라는 키워드 사용 해당 작업은 checkout
  9. uses: actions/setup-node@v3
    with:
         node-version: '14' → 노드 버전 14를 설치한다.
  10. run: npm install -g bats → run은 명령어를 실행하고 패키지 매니저로 bats 설치
  11. run: bats -v → 설치된 bats 버전 확인 명령어 실행

한 줄씩 살펴본 예제에서 우리가 알아둬야 할 것은 workflow, event(on : [push]) jobs, step, use, run 이다.

공식 문서의 예제는 이 정도로 넘어가고 활용법과 활용 예제는 다음 포스팅에 담겠습니다.

 

참고

공식 문서

https://docs.github.com/ko/actions/learn-github-actions/understanding-github-actions

 

GitHub Actions 이해 - GitHub Docs

GitHub Actions is a continuous integration and continuous delivery (CI/CD) platform that allows you to automate your build, test, and deployment pipeline. You can create workflows that build and test every pull request to your repository, or deploy merged

docs.github.com

github contexts

https://docs.github.com/en/actions/learn-github-actions/contexts#github-context

 

Contexts - GitHub Docs

Contexts are a way to access information about workflow runs, variables, runner environments, jobs, and steps. Each context is an object that contains properties, which can be strings or other objects. Contexts, objects, and properties will vary significan

docs.github.com

 

'git&github' 카테고리의 다른 글

git 브랜치(branch)  (3) 2023.02.23
git 버전 관리  (2) 2023.02.07
git&github를 알아보자.  (0) 2023.01.27
Comments