community.general.github_repo (8.5.0) — 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:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Manages Github repositories using PyGithub library.

Authentication can be done with O(access_token) or with O(username) and O(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: true
    state: present
    force_defaults: false
  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:
    description:
    - Whether the repository should be private or not.
    - Defaults to V(false) if O(force_defaults=true), which is the default in this module.
    - Defaults to V(false) if O(force_defaults=false) when creating a new repository.
    - This is only used when O(state=present).
    required: false
    type: bool

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

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

description:
    description:
    - Description for the repository.
    - Defaults to empty if O(force_defaults=true), which is the default in this module.
    - Defaults to empty if O(force_defaults=false) when creating a new repository.
    - This is only used when O(state) is V(present).
    required: false
    type: str

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

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

force_defaults:
    default: true
    description:
    - Overwrite current O(description) and O(private) attributes with defaults if set
      to V(true), which currently is the default.
    - The default for this option will be deprecated in a future version of this collection,
      and eventually change to V(false).
    required: false
    type: bool
    version_added: 4.1.0
    version_added_collection: community.general

Outputs

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