> For the complete CircleCI developer hub index, see [llms.txt](https://circleci.com/developer/llms.txt)

# trustedshops-public/github-utils

Utility for working with GitHub in CircleCI


## Commands

### checkout_repository

Check out GitHub repository


| Parameter | Type | Default | Description |
|---|---|---|---|
| `checkout_path` | string |  | Path to check the repo out for. If empty defaults to repository name without org or user prefix |
| `repository` | string |  | Name of the repository to check out including the organization or user prefix |
| `rewrite_with_token` | boolean | true | Rewrite the clone url with github token before |
| `token_env_var` | env_var_name | GITHUB_TOKEN | Name of the environment variable containing the github access token |

### publish_github_pages

Publish github pages to gh-branches page using Node.js


| Parameter | Type | Default | Description |
|---|---|---|---|
| `folder` | string | docs/ | Folder to deploy |
| `git_commit_author_email` | string |  | E-Mail to set via git config for the commit |
| `git_commit_author_name` | string |  | Author to set via git config for the commit |
| `git_commit_messages` | string | docs: Update github pages [ci skip] | Commit message to use for git |
| `repository_url` | string | https://token:${GITHUB_TOKEN}@github.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}.git | Repository url with env vars |

### rewrite_urls_with_token

Rewrite all GitHub urls using SSH (both `ssh://git@github.com/` and the SCP-style `git@github.com:` form) and HTTPS with an access token provided via environment variable


| Parameter | Type | Default | Description |
|---|---|---|---|
| `token_env_var` | env_var_name | GITHUB_TOKEN | Name of the environment variable containing the github access token |

## Examples

### git_checkout

Checkout git repository with automatic rewrite

```yaml
version: '2.1'
orbs:
  github-utils: trustedshops-public/github-utils@<version>
jobs:
  build:
    docker:
      - image: cimg/python:3.11
    steps:
      - checkout
      - github-utils/checkout_repository:
          checkout_path: build_helpers
          repository: my-org/my-shared-repo
          rewrite_with_token: true
          token_env_var: GITHUB_TOKEN
workflows:
  continuous:
    jobs:
      - build
  version: 2
```

### rewrite_urls

Rewrite urls for checkouts

```yaml
version: '2.1'
orbs:
  github-utils: trustedshops-public/github-utils@<version>
jobs:
  build:
    docker:
      - image: cimg/python:3.11
    steps:
      - checkout
      - github-utils/rewrite_urls_with_token:
          token_env_var: GITHUB_TOKEN
workflows:
  continuous:
    jobs:
      - build
  version: 2
```