{"id":18217411,"url":"https://github.com/nabeken/go-github-apps","last_synced_at":"2025-04-02T21:30:58.717Z","repository":{"id":47871697,"uuid":"285963659","full_name":"nabeken/go-github-apps","owner":"nabeken","description":"A tiny command-line utility to retrieve Github Apps Installation Token","archived":false,"fork":false,"pushed_at":"2025-03-27T22:11:11.000Z","size":355,"stargazers_count":17,"open_issues_count":2,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T23:22:37.310Z","etag":null,"topics":["cli","github","github-app"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nabeken.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-08T03:12:50.000Z","updated_at":"2025-03-27T22:10:38.000Z","dependencies_parsed_at":"2023-09-29T00:48:29.795Z","dependency_job_id":"7dd2924a-a11d-4487-85b5-83e3f128281a","html_url":"https://github.com/nabeken/go-github-apps","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabeken%2Fgo-github-apps","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabeken%2Fgo-github-apps/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabeken%2Fgo-github-apps/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabeken%2Fgo-github-apps/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nabeken","download_url":"https://codeload.github.com/nabeken/go-github-apps/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246895663,"owners_count":20851308,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","github","github-app"],"created_at":"2024-11-03T17:05:17.902Z","updated_at":"2025-04-02T21:30:58.450Z","avatar_url":"https://github.com/nabeken.png","language":"Go","readme":"# go-github-apps\n\n[![Go](https://github.com/nabeken/go-github-apps/actions/workflows/go.yml/badge.svg)](https://github.com/nabeken/go-github-apps/actions/workflows/go.yml)\n[![Test Action](https://github.com/nabeken/go-github-apps/actions/workflows/test-action.yml/badge.svg)](https://github.com/nabeken/go-github-apps/actions/workflows/test-action.yml)\n\n`go-github-apps` is a command-line tool to retrieve a Github Apps Installation Token.\n\nWhen you want to call Github APIs from machines, you would want an access token which independs of a real account.\nGithub provides several ways to issue tokens, for example:\n- **Personal Access Token via machine-user**: Before Github Apps exists, this is a typical method to issue a token but it consumes one user seats.\n- **Github Apps**: This is a new and recommended way. The problem is [it's not that easy to issue a token](https://docs.github.com/en/developers/apps/authenticating-with-github-apps#authenticating-as-a-github-app) just to automate small stuff.\n\nThis command-line tool allows you to get a token with just providing `App ID`, `Installation ID` and the private key.\n\n## Usage\n\n```sh\nUsage of ./go-github-apps:\n  -app-id int\n    \tApp ID\n  -export\n    \tshow token as 'export GITHUB_TOKEN=...'\n  -inst-id int\n    \tInstallation ID\n  -show-insts\n    \tshow all of the installations for the app\n  -url string\n        Full URL for a Github Enterprise installation, example 'https://github.example.com/api/v3'\n  -version\n    \tshow version info\n```\n\n**Example**:\n```sh\nexport GITHUB_PRIV_KEY=$(cat your-apps-2020-08-07.private-key.pem)\neval $(go-github-apps -export -app-id 12345 -inst-id 123456)\n\n# github token is now exported to GITHUB_TOKEN environment variable\n```\n\n## AppID and Installation ID\n\nAs for the App ID, you can get it via the Github Apps page.\n\nAs for the Installation ID, you can now find it with the `-show-insts` option:\n```sh\nexport GITHUB_PRIV_KEY=$(cat your-apps-2020-08-07.private-key.pem)\n\n./go-github-apps -app-id 12345 -show-insts\n[]*github.Installation{\n  \u0026github.Installation{\n    ID:       \u0026123456789,\n    NodeID:   (*string)(nil),\n    AppID:    \u002612345,\n    AppSlug:  \u0026\"go-github-apps-test\",\n    TargetID: \u00261234,\n...\n  },\n}\n```\n\nIt shows the response from [`https://api.github.com/app/installations`](https://docs.github.com/en/rest/apps/apps?apiVersion=2022-11-28#list-installations-for-the-authenticated-app).\nIf you install the app for multiple organizations and/or users, you may see multiple responses. You need to select one of the installations to use with this CLI.\n\n## Installation\n\nhttps://github.com/nabeken/go-github-apps/releases\n\n## Installation for continuous integration\n\n`install-via-release.sh` allows you to grab the binary into the current working directory so that you can easy integrate it into your pipiline.\n\n**Example**:\n```sh\ncurl -sSLf https://raw.githubusercontent.com/nabeken/go-github-apps/master/install-via-release.sh | bash -s -- -v v0.0.3\nsudo cp go-github-apps /usr/local/bin\n```\n\n## Github Actions\n\nAs of Aug, 2024, Github provides [the official actions](https://github.com/actions/create-github-app-token) to create a GitHub App installation access token. Please consider migrating to the official one.\n\nAt certain point, I'll obsolete the github action in this repository.\n\n### Different from `actions/create-github-app-token`\n\n`go-github-apps` always receives an installation token for the installation under an installed owner (organization) where the official action only requires for a current repository.\n\nIf you want to have an installation that works for the installation under installed owner (organization), you need to specify `owner` in the workflow:\n\n```yaml\nsteps:\n- uses: actions/create-github-app-token@v1\n  id: app-token\n  with:\n    app-id: ${{ vars.APP_ID }}\n    private-key: ${{ secrets.PRIVATE_KEY }}\n    owner: ${{ github.repository_owner }}\n```\n\n### `go-github-apps`'s Github Actions\n\nYou can automate issuing a token for Github Actions with `go-github-apps` but it will be obsoleted in the future as described above.\n\nExample:\n```yml\n- name: Get GITHUB_TOKEN for Github Apps\n  uses: nabeken/go-github-apps@v0\n  id: go-github-apps\n  with:\n    installation_id: ${{ secrets.installation_id }}\n    app_id: ${{ secrets.app_id }}\n    private_key: ${{ secrets.private_key }}\n\n- name: Test Github API call\n  run: |\n    curl --fail -H 'Authorization: token ${{ steps.go-github-apps.outputs.app_github_token }}' https://api.github.com/\n```\n\n## Release\n\n- Merge a release PR, created by release-please action\n- Renovate will update \"version\" in several places once it detects a new version of `go-github-apps` so you can merge it if you're happy with the result\n  - \"version\" in the github actions for testing\n  - default \"version\" in `action.yml`\n- Tag `v0`\n  - Run [`Bump the actions version`](https://github.com/nabeken/go-github-apps/actions/workflows/update_actions_tag.yml) to update `v0` tag with the latest main branch\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnabeken%2Fgo-github-apps","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnabeken%2Fgo-github-apps","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnabeken%2Fgo-github-apps/lists"}