community.general.github_repo (3.8.10) — module

Manage your repositories on Github

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

Authors: Álvaro Torres Cogollo (@atorrescogollo)

Install collection

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


Add to requirements.yml

  collections:
    - name: community.general
      version: 3.8.10

Description

Manages Github repositories using PyGithub library.

Authentication can be done with I(access_token) or with I(username) and I(password).


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a Github repository
  community.general.github_repo:
    access_token: mytoken
    organization: MyOrganization
    name: myrepo
    description: "Just for fun"
    private: yes
    state: present
  register: result
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Delete the repository
  community.general.github_repo:
    username: octocat
    password: password
    organization: MyOrganization
    name: myrepo
    state: absent
  register: result

Inputs

    
name:
    description:
    - Repository name.
    required: true
    type: str

state:
    choices:
    - absent
    - present
    default: present
    description:
    - Whether the repository should exist or not.
    required: false
    type: str

api_url:
    default: https://api.github.com
    description:
    - URL to the GitHub API if not using github.com but you own instance.
    type: str
    version_added: 3.5.0
    version_added_collection: community.general

private:
    default: false
    description:
    - Whether the new repository should be private or not.
    - This is only used when I(state) is C(present).
    required: false
    type: bool

password:
    description:
    - Password used for authentication.
    - This is only needed when not using I(access_token).
    required: false
    type: str

username:
    description:
    - Username used for authentication.
    - This is only needed when not using I(access_token).
    required: false
    type: str

description:
    default: ''
    description:
    - Description for the repository.
    - This is only used when I(state) is C(present).
    required: false
    type: str

access_token:
    description:
    - Token parameter for authentication.
    - This is only needed when not using I(username) and I(password).
    required: false
    type: str

organization:
    description:
    - Organization for the repository.
    - When I(state) is C(present), the repository will be created in the current user
      profile.
    required: false
    type: str

Outputs

repo:
  description: Repository information as JSON. See U(https://docs.github.com/en/rest/reference/repos#get-a-repository).
  returned: success and I(state) is C(present)
  type: dict