项目作者: tibdex

项目描述 :
Impersonate a GitHub App in a GitHub Action
高级语言: TypeScript
项目地址: git://github.com/tibdex/github-app-token.git
创建时间: 2020-04-11T12:43:00Z
项目社区:https://github.com/tibdex/github-app-token

开源协议:MIT License

下载


GitHub App Token

This JavaScript GitHub Action can be used to impersonate a GitHub App when secrets.GITHUB_TOKEN‘s limitations are too restrictive and a personal access token is not suitable.

For instance, from GitHub Actions’ docs:

When you use the repository’s GITHUB_TOKEN to perform tasks, events triggered by the GITHUB_TOKEN, with the exception of workflow_dispatch and repository_dispatch, will not create a new workflow run.
This prevents you from accidentally creating recursive workflow runs.
For example, if a workflow run pushes code using the repository’s GITHUB_TOKEN, a new workflow will not run even when the repository contains a workflow configured to run when push events occur.

A workaround is to use a personal access token from a personal user/bot account.
However, for organizations, GitHub Apps are a more appropriate automation solution.

Example Workflow

  1. jobs:
  2. job:
  3. runs-on: ubuntu-latest
  4. steps:
  5. - id: create_token
  6. uses: tibdex/github-app-token@v2
  7. with:
  8. app_id: ${{ secrets.APP_ID }}
  9. # Optional.
  10. # github_api_url: https://api.example.com
  11. # Optional.
  12. # installation_retrieval_mode: id
  13. # Optional.
  14. # installation_retrieval_payload: 1337
  15. # Optional.
  16. # Using a YAML multiline string to avoid escaping the JSON quotes.
  17. # permissions: >-
  18. # {"pull_requests": "read"}
  19. private_key: ${{ secrets.PRIVATE_KEY }}
  20. # Optional.
  21. # repositories: >-
  22. # ["actions/toolkit", "github/docs"]
  23. # Optional.
  24. # revoke: false
  25. - run: "echo 'The created token is masked: ${{ steps.create_token.outputs.token }}'"

Another use case for this action can (or could) be found in GitHub’s own docs.