{"meta":{"title":"복합 작업 만들기","intro":"이 자습서에서는 복합 작업을 빌드하는 방법을 알아봅니다.","product":"GitHub Actions","breadcrumbs":[{"href":"/ko/actions","title":"GitHub Actions"},{"href":"/ko/actions/tutorials","title":"자습서"},{"href":"/ko/actions/tutorials/create-actions","title":"액션 만들기"},{"href":"/ko/actions/tutorials/create-actions/create-a-composite-action","title":"복합 작업 만들기"}],"documentType":"article"},"body":"# 복합 작업 만들기\n\n이 자습서에서는 복합 작업을 빌드하는 방법을 알아봅니다.\n\n## 소개\n\n이 가이드에서는 패키지된 복합 작업을 만들고 사용하는 데 필요한 기본 구성 요소에 대해 알아봅니다. 작업을 패키지하는 데 필요한 구성 요소에 가이드의 초점을 맞추기 위해 작업 코드의 기능은 최소화됩니다. 작업은 \"Hello World\" 및 \"Goodbye\"를 인쇄하거나 사용자 지정 이름을 제공하는 경우 \"Hello \\[who-to-greet]\" 및 \"Goodbye\"를 출력합니다. 이 작업은 또한 난수를 `random-number` 출력 변수에 매핑하고 `goodbye.sh`라는 스크립트를 실행합니다.\n\n이 프로젝트를 완료한 후에는 고유한 복합 작업을 빌드하고 워크플로에서 테스트하는 방법을 이해해야 합니다.\n\n> \\[!WARNING]\n> 워크플로와 작업을 만들 때는 코드가 공격자의 신뢰할 수 없는 입력을 실행할 수 있는지 항상 고려해야 합니다. 특정 컨텍스트는 공격자가 자신의 악성 콘텐츠를 삽입할 수 있으므로 신뢰할 수 없는 입력으로 취급해야 합니다. 자세한 내용은 [안전 사용 참조](/ko/actions/security-guides/security-hardening-for-github-actions#understanding-the-risk-of-script-injections)을(를) 참조하세요.\n\n### 복합 작업 및 재사용 가능한 워크플로\n\n복합 작업을 사용하면 일련의 워크플로 작업 단계를 단일 작업으로 수집한 다음, 여러 워크플로에서 단일 작업 단계로 실행할 수 있습니다. 재사용 가능한 워크플로는 다른 워크플로 내에서 전체 워크플로를 실행할 수 있도록 하여 중복을 방지하는 또 다른 방법을 제공합니다. 자세한 내용은 [워크플로 구성 재사용](/ko/actions/using-workflows/avoiding-duplication)을(를) 참조하세요.\n\n## 필수 조건\n\n> \\[!NOTE]\n> 이 예제에서는 별도의 리포지토리 내에서 복합 작업을 만드는 방법을 설명합니다. 그러나 동일한 리포지토리 내에서 복합 작업을 만들 수 있습니다. 자세한 내용은 [복합 작업 만들기](/ko/actions/creating-actions/creating-a-composite-action#creating-a-composite-action-within-the-same-repository)을(를) 참조하세요.\n\n시작하기 전에 .에 리포지토리를 만듭니다 GitHub.\n\n1. 에 새 공용 리포지토리를 만듭니다 GitHub. 리포지토리 이름을 선택하거나 다음 `hello-world-composite-action` 예제를 사용할 수 있습니다. 파일은 프로젝트가 GitHub에 업로드된 후에 추가할 수 있습니다. 자세한 내용은 [새 리포지토리 만들기](/ko/repositories/creating-and-managing-repositories/creating-a-new-repository)을(를) 참조하세요.\n\n2. 컴퓨터에 리포지토리를 복제합니다. 자세한 내용은 [리포지토리 복제](/ko/repositories/creating-and-managing-repositories/cloning-a-repository)을(를) 참조하세요.\n\n3. 터미널에서 디렉터리를 새 리포지토리로 변경합니다.\n\n   ```shell copy\n   cd hello-world-composite-action\n   ```\n\n4. ```\n          `hello-world-composite-action` 리포지토리에서 다음 예제 코드로 `goodbye.sh`라는 새 파일을 만드세요.\n   ```\n\n   ```shell copy\n   echo \"echo Goodbye\" > goodbye.sh\n   ```\n\n5. 터미널에서 `goodbye.sh` 실행 파일을 만듭니다.\n\n   <div class=\"ghd-tool linux\">\n\n   ```shell copy\n   chmod +x goodbye.sh\n   ```\n\n   </div>\n\n   <div class=\"ghd-tool mac\">\n\n   ```shell copy\n   chmod +x goodbye.sh\n   ```\n\n   </div>\n\n   <div class=\"ghd-tool windows\">\n\n   ```shell copy\n   git add --chmod=+x -- goodbye.sh\n   ```\n\n   </div>\n\n6. 터미널에서 `goodbye.sh` 파일을 체크 인합니다.\n\n   <div class=\"ghd-tool linux\">\n\n   ```shell copy\n   git add goodbye.sh\n   git commit -m \"Add goodbye script\"\n   git push\n   ```\n\n   </div>\n\n   <div class=\"ghd-tool mac\">\n\n   ```shell copy\n   git add goodbye.sh\n   git commit -m \"Add goodbye script\"\n   git push\n   ```\n\n   </div>\n\n   <div class=\"ghd-tool windows\">\n\n   ```shell copy\n   git commit -m \"Add goodbye script\"\n   git push\n   ```\n\n   </div>\n\n## 작업 메타데이터 파일 만들기\n\n1. ```\n          `hello-world-composite-action` 리포지토리에서 `action.yml`라는 새 파일을 만들고 다음 예제 코드를 추가합니다. 이 구문에 대한 자세한 내용은 [AUTOTITLE](/actions/creating-actions/metadata-syntax-for-github-actions#runs-for-composite-actions)을(를) 참조하세요.\n   ```\n\n   ```yaml copy\n   name: 'Hello World'\n   description: 'Greet someone'\n   inputs:\n     who-to-greet:  # id of input\n       description: 'Who to greet'\n       required: true\n       default: 'World'\n   outputs:\n     random-number:\n       description: \"Random number\"\n       value: ${{ steps.random-number-generator.outputs.random-number }}\n   runs:\n     using: \"composite\"\n     steps:\n       - name: Set Greeting\n         run: echo \"Hello $INPUT_WHO_TO_GREET.\"\n         shell: bash\n         env:\n           INPUT_WHO_TO_GREET: ${{ inputs.who-to-greet }}\n\n       - name: Random Number Generator\n         id: random-number-generator\n         run: echo \"random-number=$(echo $RANDOM)\" >> $GITHUB_OUTPUT\n         shell: bash\n\n       - name: Set GitHub Path\n         run: echo \"$GITHUB_ACTION_PATH\" >> $GITHUB_PATH\n         shell: bash\n         env:\n           GITHUB_ACTION_PATH: ${{ github.action_path }}\n\n       - name: Run goodbye.sh\n         run: goodbye.sh\n         shell: bash\n\n   ```\n\n   이 파일은 `who-to-greet` 입력을 정의하고, 임의 생성된 숫자를 `random-number` 출력 변수에 매핑하며, 실행기 시스템 경로에 동작의 경로를 추가(실행 중 `goodbye.sh` 스크립트를 찾기 위해)하고, `goodbye.sh` 스크립트를 실행합니다.\n\n   출력 관리에 대한 자세한 정보는 [메타데이터 구문 참조](/ko/actions/creating-actions/metadata-syntax-for-github-actions#outputs-for-composite-actions)을(를) 참조하세요.\n\n   ```\n          `github.action_path` 사용 방법에 대한 자세한 내용은 [AUTOTITLE](/actions/learn-github-actions/contexts#github-context)을(를) 참조하세요.\n   ```\n\n2. 터미널에서 `action.yml` 파일을 체크 인합니다.\n\n   ```shell copy\n   git add action.yml\n   git commit -m \"Add action\"\n   git push\n   ```\n\n3. 터미널에서 태그를 추가합니다. 이 예제에서는 `v1`이라는 태그를 사용합니다. 자세한 내용은 [사용자 지정 작업 정보](/ko/actions/creating-actions/about-custom-actions#using-release-management-for-actions)을(를) 참조하세요.\n\n   ```shell copy\n   git tag -a -m \"Description of this release\" v1\n   git push --follow-tags\n   ```\n\n## 워크플로에서 작업 테스트\n\n다음 워크플로 코드는 [복합 작업 만들기](/ko/actions/creating-actions/creating-a-composite-action#creating-an-action-metadata-file)에서 수행한 완료된 hello world 작업을 사용합니다.\n\n워크플로 코드를 다른 리포지토리의 `.github/workflows/main.yml` 파일에 복사하여 `OWNER` 및 `SHA`를 각각 리포지토리 소유자와 사용할 커밋의 SHA로 바꿉니다.\n`who-to-greet` 입력을 자신의 이름으로 바꿀 수도 있습니다.\n\n```yaml copy\non: [push]\n\njobs:\n  hello_world_job:\n    runs-on: ubuntu-latest\n    name: A job to say hello\n    steps:\n      - uses: actions/checkout@v6\n      - id: foo\n        uses: OWNER/hello-world-composite-action@SHA\n        with:\n          who-to-greet: 'Mona the Octocat'\n      - run: echo random-number \"$RANDOM_NUMBER\"\n        shell: bash\n        env:\n          RANDOM_NUMBER: ${{ steps.foo.outputs.random-number }}\n```\n\n리포지토리에서 **작업** 탭을 클릭하고 최신 워크플로 실행을 선택합니다. 출력에는 “Hello Mona the Octocat”, “Goodbye” 스크립트의 결과와 난수가 포함되어야 합니다.\n\n## 동일한 리포지토리 내에서 복합 작업 만들기\n\n1. ```\n          `hello-world-composite-action`라는 새 하위 폴더를 만듭니다. 이 폴더는 리포지토리 내의 모든 하위 폴더에 배치할 수 있습니다. 하지만 조직을 더 쉽게 정리하기 위해서는 `.github/actions` 하위 폴더에 배치하는 것이 더 좋습니다.\n   ```\n\n2. ```\n          `hello-world-composite-action` 폴더에서 `goodbye.sh` 스크립트를 만들기 위해 동일한 단계를 수행합니다.\n   ```\n\n   ```shell copy\n   echo \"echo Goodbye\" > goodbye.sh\n   ```\n\n   <div class=\"ghd-tool linux\">\n\n   ```shell copy\n   chmod +x goodbye.sh\n   ```\n\n   </div>\n\n   <div class=\"ghd-tool mac\">\n\n   ```shell copy\n   chmod +x goodbye.sh\n   ```\n\n   </div>\n\n   <div class=\"ghd-tool windows\">\n\n   ```shell copy\n   git add --chmod=+x -- goodbye.sh\n   ```\n\n   </div>\n\n   <div class=\"ghd-tool linux\">\n\n   ```shell copy\n   git add goodbye.sh\n   git commit -m \"Add goodbye script\"\n   git push\n   ```\n\n   </div>\n\n   <div class=\"ghd-tool mac\">\n\n   ```shell copy\n   git add goodbye.sh\n   git commit -m \"Add goodbye script\"\n   git push\n   ```\n\n   </div>\n\n   <div class=\"ghd-tool windows\">\n\n   ```shell copy\n   git commit -m \"Add goodbye script\"\n   git push\n   ```\n\n   </div>\n\n3. ```\n          `hello-world-composite-action` 폴더에 `action.yml`의 단계에 따라 [](/actions/creating-actions/creating-a-composite-action#creating-an-action-metadata-file) 파일을 만듭니다.\n   ```\n\n4. 이 작업을 진행할 때는 `action.yml` 키에 복합 작업의 `uses` 파일이 위치한 폴더의 상대 경로를 지정합니다. 아래 예제에서는 `.github/actions/hello-world-composite-action` 폴더에 작업이 있다고 가정합니다.\n\n```yaml copy\non: [push]\n\njobs:\n  hello_world_job:\n    runs-on: ubuntu-latest\n    name: A job to say hello\n    steps:\n      - uses: actions/checkout@v6\n      - id: foo\n        uses: ./.github/actions/hello-world-composite-action\n        with:\n          who-to-greet: 'Mona the Octocat'\n      - run: echo random-number \"$RANDOM_NUMBER\"\n        shell: bash\n        env:\n          RANDOM_NUMBER: ${{ steps.foo.outputs.random-number }}\n```"}