예시 워크플로우 만들기
예시 워크플로우 만들기
이 튜토리얼에서는 push 이벤트에 의해 트리거되는 기본 워크플로우를 직접 만드는 방법을 알려드릴게요. 코드가 저장소에 푸시될 때 자동으로 실행되는 워크플로우를 만들어 볼 거예요.
출처: 문서
본문
Introduction
이 가이드는 코드가 저장소에 푸시될 때 트리거되는 기본 워크플로우를 만드는 방법을 보여드릴게요.
미리 구성된 워크플로우로 시작하려면 actions/starter-workflows 저장소의 템플릿 목록을 살펴보세요. 자세한 내용은 Using workflow templates 문서를 참고하세요.
[!IMPORTANT] 워크플로우 보안과 GitHub Actions 기능의 안전한 사용에 대한 모범 사례에 대해 더 알아보려면 Secure use reference 문서를 참고하세요.
Creating an example workflow
GitHub Actions는 YAML 문법을 사용해서 워크플로우를 정의해요. 각 워크플로우는 코드 저장소의 .github/workflows라는 디렉터리에 별도의 YAML 파일로 저장돼요.
코드가 푸시될 때마다 일련의 명령을 자동으로 트리거하는 예시 워크플로우를 저장소에 만들 수 있어요. 이 워크플로우에서 GitHub Actions는 푸시된 코드를 체크아웃하고, bats 테스트 프레임워크를 설치하고, bats 버전을 출력하는 기본 명령 bats -v를 실행해요.
-
저장소에 워크플로우 파일을 저장할
.github/workflows/디렉터리를 만드세요. -
.github/workflows/디렉터리에learn-github-actions.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@v6 - uses: actions/setup-node@v7 with: node-version: '24' - run: npm install -g bats - run: bats -v -
이러한 변경 사항을 커밋하고 GitHub 저장소에 푸시하세요.
새 GitHub Actions 워크플로우 파일이 이제 저장소에 설치되었고, 누군가 저장소에 변경 사항을 푸시할 때마다 자동으로 실행돼요. 워크플로우 실행 기록에 대한 자세한 내용을 보려면 Viewing the activity for a workflow run 문서를 참고하세요.
Understanding the workflow file
YAML 문법이 워크플로우 파일을 만드는 데 어떻게 사용되는지 이해할 수 있도록, 이 섹션에서는 소개에서 본 예시의 각 줄을 설명할게요.
# Optional - The name of the workflow as it will appear in the "Actions" tab of the GitHub repository. If this field is omitted, the name of the workflow file will be used instead.
name: learn-github-actions
# Optional - The name for workflow runs generated from the workflow, which will appear in the list of workflow runs on your repository's "Actions" tab. This example uses an expression with the `github` context to display the username of the actor that triggered the workflow run. For more information, see [AUTOTITLE](/actions/using-workflows/workflow-syntax-for-github-actions#run-name).
run-name: ${{ github.actor }} is learning GitHub Actions
# Specifies the trigger for this workflow. This example uses the `push` event, so a workflow run is triggered every time someone pushes a change to the repository or merges a pull request. This is triggered by a push to every branch; for examples of syntax that runs only on pushes to specific branches, paths, or tags, see [AUTOTITLE](/actions/reference/workflow-syntax-for-github-actions#onpushpull_requestpull_request_targetpathspaths-ignore).
on: [push]
# Groups together all the jobs that run in the `learn-github-actions` workflow.
jobs:
# Defines a job named `check-bats-version`. The child keys will define properties of the job.
check-bats-version:
# Configures the job to run on the latest version of an Ubuntu Linux runner. This means that the job will execute on a fresh virtual machine hosted by GitHub. For syntax examples using other runners, see [AUTOTITLE](/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on)
runs-on: ubuntu-latest
# Groups together all the steps that run in the `check-bats-version` job. Each item nested under this section is a separate action or shell script.
steps:
# The `uses` keyword specifies that this step will run the `actions/checkout@v6` action. This is an action that checks out your repository onto the runner, allowing you to run scripts or other actions against your code (such as build and test tools). You should use the checkout action any time your workflow will use the repository's code.
- uses: actions/checkout@v6
# This step uses the `actions/setup-node@v7` action to install the specified version of the Node.js. (This example uses version 24.) This puts both the `node` and `npm` commands in your `PATH`.
- uses: actions/setup-node@v7
with:
node-version: '24'
# The `run` keyword tells the job to execute a command on the runner. In this case, you are using `npm` to install the `bats` software testing package.
- run: npm install -g bats
# Finally, you'll run the `bats` command with a parameter that outputs the software version.
- run: bats -v
Visualizing the workflow file
이 다이어그램에서 방금 만든 워크플로우 파일과 GitHub Actions 구성 요소가 계층적으로 어떻게 구성되는지 볼 수 있어요. 각 단계는 단일 액션 또는 셸 스크립트를 실행해요. 1단계와 2단계는 액션을 실행하고, 3단계와 4단계는 셸 스크립트를 실행해요. 워크플로우를 위한 미리 빌드된 액션을 더 찾으려면 Using pre-written building blocks in your workflow 문서를 참고하세요.

Viewing the activity for a workflow run
워크플로우가 트리거되면 워크플로우를 실행하는 *워크플로우 실행(workflow run)*이 생성돼요. 워크플로우 실행이 시작된 후에는 GitHub에서 실행 진행 상황의 시각화 그래프를 보고 각 단계의 활동을 확인할 수 있어요.
-
GitHub에서 저장소의 메인 페이지로 이동하세요.
-
저장소 이름 아래에서 Actions을 클릭하세요.

-
왼쪽 사이드바에서 보려는 워크플로우를 클릭하세요.

-
워크플로우 실행 목록에서 실행 이름을 클릭해서 워크플로우 실행 요약을 확인하세요.
-
왼쪽 사이드바 또는 시각화 그래프에서 보고 싶은 job을 클릭하세요.
-
단계의 결과를 보려면 단계를 클릭하세요.