{"meta":{"title":"워크플로에서 인증에 GITHUB_TOKEN 사용","intro":"GITHUB_TOKEN를 사용하여 GitHub Actions를 대신해 인증하는 방법을 알아봅니다.","product":"GitHub Actions","breadcrumbs":[{"href":"/ko/enterprise-server@3.18/actions","title":"GitHub Actions"},{"href":"/ko/enterprise-server@3.18/actions/tutorials","title":"자습서"},{"href":"/ko/enterprise-server@3.18/actions/tutorials/authenticate-with-github_token","title":"GITHUB_TOKEN을 사용하여 인증"}],"documentType":"article"},"body":"# 워크플로에서 인증에 GITHUB_TOKEN 사용\n\nGITHUB_TOKEN를 사용하여 GitHub Actions를 대신해 인증하는 방법을 알아봅니다.\n\n이 자습서에서는 작업에 토큰을 전달하고, API 요청을 수행하고, 보안 자동화에 대한 사용 권한을 구성하는 예제를 포함하여 워크플로에서 인증 `GITHUB_TOKEN` 에 사용하는 GitHub Actions 방법을 안내합니다.\n\n참조 정보는 [GitHub Actions에 대한 워크플로 구문](/ko/enterprise-server@3.18/actions/reference/workflows-and-actions/workflow-syntax#permissions)을(를) 참조하세요.\n\n## 워크플로에서 `GITHUB_TOKEN` 사용\n\n`GITHUB_TOKEN`\n\n`${{ secrets.GITHUB_TOKEN }}`와 같이 시크릿을 참조하는 표준 구문을 사용하여 를 사용할 수 있습니다. 토큰을 `GITHUB_TOKEN` 작업에 대한 입력으로 전달하거나 인증된 GitHub API 요청을 만드는 데 사용하는 예제입니다.\n\n> \\[!IMPORTANT]\n> 워크플로가 `GITHUB_TOKEN`을 작업에 명시적으로 전달하지 않더라도 작업은 `github.token` 컨텍스트를 통해 `GITHUB_TOKEN`에 액세스할 수 있습니다. 좋은 보안 사례로, 항상 `GITHUB_TOKEN`에 부여된 권한을 제한하여 필요한 최소 액세스 권한만 갖도록 해야 합니다. 자세한 내용은 [GitHub Actions에 대한 워크플로 구문](/ko/enterprise-server@3.18/actions/reference/workflows-and-actions/workflow-syntax#permissions)을(를) 참조하세요.\n\n### 예제 1: 입력으로 `GITHUB_TOKEN` 전달\n\n이 예제 워크플로는 [GitHub CLI](/ko/enterprise-server@3.18/actions/how-tos/write-workflows/choose-what-workflows-do/use-github-cli)를 사용하며, 이 경우 `GITHUB_TOKEN` 입력 매개 변수의 값으로 `GH_TOKEN`가 필요합니다.\n\n```yaml copy\nname: Open new issue\non: workflow_dispatch\n\njobs:\n  open-issue:\n    runs-on: ubuntu-latest\n    permissions:\n      contents: read\n      issues: write\n    steps:\n      - run: |\n          gh issue --repo ${{ github.repository }} \\\n            create --title \"Issue title\" --body \"Issue body\"\n        env:\n          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n```\n\n### 예제 2: REST API 호출\n\n`GITHUB_TOKEN`은 인증된 API 호출을 수행하는 데 사용할 수 있습니다. 이 예제 워크플로는 REST API를 GitHub 사용하여 문제를 만듭니다.\n\n```yaml\nname: Create issue on commit\n\non: [ push ]\n\njobs:\n  create_issue:\n    runs-on: ubuntu-latest\n    permissions:\n      issues: write\n    steps:\n      - name: Create issue using REST API\n        run: |\n          curl --request POST \\\n          --url http(s)://HOSTNAME/api/v3/repos/${{ github.repository }}/issues \\\n          --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \\\n          --header 'content-type: application/json' \\\n          --data '{\n            \"title\": \"Automated issue for commit: ${{ github.sha }}\",\n            \"body\": \"This issue was automatically created by the GitHub Action workflow **${{ github.workflow }}**. \\n\\n The commit hash was: _${{ github.sha }}_.\"\n            }' \\\n          --fail\n```\n\n## `GITHUB_TOKEN`에 대한 권한 수정\n\n워크플로 파일의 `permissions` 키를 사용하여 전체 워크플로 또는 개별 작업에 대한 `GITHUB_TOKEN`의 권한을 수정할 수 있습니다. 이렇게 하면 워크플로 또는 작업에 필요한 최소 권한을 구성할 수 있습니다. 적절한 보안 사례로, `GITHUB_TOKEN`에 최소한의 액세스 권한을 부여해야 합니다.\n\n사용 가능한 권한 목록과 매개 변수가 있는 이름을 보려면 [개인용 액세스 토큰 관리](/ko/enterprise-server@3.18/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#account-permissions)을(를) 참조하세요.\n\n이 문서의 앞부분에 있는 워크플로 예제 두 개는 워크플로 수준과 작업 수준에서 사용 중인 `permissions` 키를 보여 줍니다.\n\n## 추가 권한 부여\n\n`GITHUB_TOKEN`에서 사용할 수 없는 권한이 필요한 토큰이 필요하면 GitHub App를 만들고 워크플로 내에서 설치 액세스 토큰을 생성하세요. 자세한 내용은 [GitHub Actions 워크플로에서 GitHub 앱을 사용하여 인증된 API 요청 만들기](/ko/enterprise-server@3.18/apps/creating-github-apps/authenticating-with-a-github-app/making-authenticated-api-requests-with-a-github-app-in-a-github-actions-workflow)을(를) 참조하세요. 대신 personal access token를 생성한 다음 리포지토리에 시크릿으로 저장하고, `${{ secrets.SECRET_NAME }}` 구문을 사용해 워크플로에서 해당 토큰을 사용할 수 있습니다. 자세한 내용은 [개인용 액세스 토큰 관리](/ko/enterprise-server@3.18/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) 및 [GitHub Actions에서 비밀 사용](/ko/enterprise-server@3.18/actions/how-tos/write-workflows/choose-what-workflows-do/use-secrets)을(를) 참조하세요.\n\n## 다음 단계\n\n* [GITHUB\\_TOKEN](/ko/enterprise-server@3.18/actions/concepts/security/github_token)\n* [GitHub Actions에 대한 워크플로 구문](/ko/enterprise-server@3.18/actions/reference/workflows-and-actions/workflow-syntax#permissions)"}