Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
unlock

GitHub Action

Get an app token in an Actions workflow.

0.2

Get an app token in an Actions workflow.

unlock

Get an app token in an Actions workflow.

Useful for remedying the problem of restricted access tokens, especially on PRs from forks

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Get an app token in an Actions workflow.

uses: machine-learning-apps/actions-app-token@0.2

Learn more about this action in machine-learning-apps/actions-app-token

Choose a version

Actions Status

Impersonate Your GitHub App In A GitHub Action

This action helps you retrieve an authenticated app token with an app id and a private key. You can use this key inside an actions workflow instead of GITHUB_TOKEN, in cases where the GITHUB_TOKEN has restricted rights

Why Would You Do This?

For example, a pull request events from forked repositories are hydrated with a GITHUB_TOKEN that has read-only access. Unfortunately, this means that PRs opened from forks cannot use Actions like the first-interaction Action that greets new contributors, because the token does not have authority to comment on the PR.

Usage

  1. Register a GitHub App (or use an existing one you own), and install this app on your repos. No need to setup an endpoint or a webhook (you can put in fake urls for these) as you can use this app for the purposes of Action workflows only if you like.

  2. Creation a workflow file in .github/workflows/

    See action.yml for the api spec.

Example:

steps:
- name: Get token
  id: get_token
  uses: machine-learning-apps/actions-app-token@master
  with:
    APP_PEM: ${{ secrets.APP_PEM }}
    APP_ID: ${{ secrets.APP_ID }}

# see https://github.com/actions/first-interaction
- name: greet new contributors
  uses: actions/first-interaction@v1
  with:
    repo-token: ${{ steps.get_token.output.token }} # instead of ${{ secrets.GITHUB_TOKEN }}
    pr-message: 'Message that will be displayed on users' first pr. Look, a `code block` for markdown.'

License

The scripts and documentation in this project are released under the MIT License.

Notes

This action is being actively used for fastpages-chatops