
Github Action은 Github에서 공식적으로 제공하는 CI/CD 툴, 다시 말해 개발의 work flow를 자동화 할 수 있게 도와주고 빌드, 테스트 및 배포 파이프라인을 자동화 할 수 있는 지속적 통합 및 지속적 배포(CI/CD) 플랫폼이다. 리포지토리에 대한 모든 pull 요청을 빌드 및 테스트하는 work flow를 생성하거나 Merge된 pull 요청을 프로덕션에 배포할 수 있다.

Github Action은 event, job, step을 정의하기 위해 YAML 파일을 사용한다. workflow를 구성할 레포지토리에 .github/workflows 디렉토리 안에 test-github-actions.yml 형태로 파일을 생성한다.
name: learn-github-actions
on:
push:
branches: [ master, dev ]
pull_request:
branches: [ master ]
paths:
- "**.js"
paths-ignore:
- "doc/**"
jobs:
build:
strategy:
matrix:
node-version: [10.x, 12.x]
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: My First Step
run:
npm install
npm test
npm build
- name: Cache yarn dependencies
uses: actions/cache@v1
id: yarn-cache
with:
path: node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
name: learn-github-actions
on:
push:
branches: [ master, dev ]
pull_request:
branches: [ master ]
paths:
- "**.js"
paths-ignore:
- "doc/**"
jobs:
build:
strategy:
matrix:
node-version: [10.x, 12.x]
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: My First Step
run:
npm install
npm test
npm build
- name: Cache yarn dependencies
uses: actions/cache@v1
id: yarn-cache
with:
path: node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
runs-on : 해당 job을 어떤 OS에서 실행할 것인지 명시한다.steps : job이 가질 수 있는 동작의 나열. 각각의 step은 독립적인 프로세스를 가진다.uses : 해당 step에서 사용할 액션으로 Github 마켓플레이스에 올라온 action들을 사용할 수도 있다. {owner}/{repo}@{ref|version} 의 형태를 지닌다.name : step의 이름run : job에 할당된 컴퓨팅 자원의 shell을 이용하여 커맨드 라인을 실행한다.env : 해당 job에서 사용할 환경 변수를 key/value 형태로 설정한다.strategy : 여러 환경에서의 테스트/배포를 위해서 빌드 matrix를 구성한다.with : 해당 action에 의해 정의되는 input 파라미터로 key/value 페어로 되어 있다. input 파라미터는 환경 변수로 설정되고, 'INPUT_'이라는 prefix가 붙는다.