community.general.github_app_access_token (8.5.0) — lookup

Obtain short-lived Github App Access tokens

| "added in version" 8.2.0 of community.general"

Authors: Poh Wei Sheng (@weisheng-p)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

This generates a Github access token that can be used with a C(git) command, if you use a Github App.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Get access token to be used for git checkout with app_id=123456, installation_id=64209
  ansible.builtin.git:
    repo: >-
      https://x-access-token:{{ github_token }}@github.com/hidden_user/super-secret-repo.git
    dest: /srv/checkout
  vars:
    github_token: >-
      lookup('community.general.github_app_access_token', key_path='/home/to_your/key',
             app_id='123456', installation_id='64209')

Inputs

    
app_id:
    description:
    - Your GitHub App ID, you can find this in the Settings page.
    required: true
    type: str

key_path:
    description:
    - Path to your private key.
    required: true
    type: path

token_expiry:
    default: 600
    description:
    - How long the token should last for in seconds.
    type: int

installation_id:
    description:
    - The installation ID that contains the git repository you would like access to.
    - As of 2023-12-24, this can be found via Settings page > Integrations > Application.
      The last part of the URL in the configure button is the installation ID.
    - Alternatively, you can use PyGithub (U(https://github.com/PyGithub/PyGithub)) to
      get your installation ID.
    required: true
    type: str

Outputs

_raw:
  description: A one-element list containing your GitHub access token.
  elements: str
  type: list