actions / create-github-app-token

GitHub Action for creating a GitHub App Installation Access Token
https://github.com/marketplace/actions/create-github-app-token
MIT License
321 stars 46 forks source link

feat(outputs): `app-slug` and `installation-id` #105

Closed maboloshi closed 4 months ago

maboloshi commented 5 months ago

It is convenient to use https://api.github.com/users/$app_slug[bot] to obtain the corresponding account ID later. Then build Signed-off-by: $app_slug[bot] <$id+$app_slug[bot]@users.noreply.github.com>.

Currently, there is no Linux environment to build test snapshot files

maboloshi commented 5 months ago

test log https://github.com/maboloshi/create-github-app-token/actions/runs/7973503597/job/21767476883

gr2m commented 5 months ago

Then build Signed-off-by: $app_slug[bot] <$id+$app_slug[bot]@users.noreply.github.com>.

that suggest you'd need the app ID as well? I'm not sure if the app ID or installation ID is needed for this to work. I know that for commits, you should use the installation ID, see this patch for example: https://github.com/octokit/core.js/commit/80c9bee698498ff3c14c95f5ac76d7f2d9d755bc.patch

29139614 is the installation ID. The app ID is 2740

maboloshi commented 5 months ago

I'm currently using the GitHub GRAPHQL api for commits, which automatically sets the author information using the account information corresponding to the token. I currently want to build Signed-off-by with reference to this format. image Request https://api.github.com/users/action-assistant[bot] to get the following information. Where id is the ID of the virtual account corresponding to the token produced by the github app.

{
  "login": "action-assistant[bot]",
  "id": 152410706,
......
}

action-assistant is the github app slug I got from the features added so far.

maboloshi commented 5 months ago

Then build Signed-off-by: $app_slug[bot] <$id+$app_slug[bot]@users.noreply.github.com>.

that suggest you'd need the app ID as well? I'm not sure if the app ID or installation ID is needed for this to work. I know that for commits, you should use the installation ID, see this patch for example: https://github.com/octokit/core.js/commit/80c9bee698498ff3c14c95f5ac76d7f2d9d755bc.patch

29139614 is the installation ID. The app ID is 2740

Actually, 29139614 is not the installation ID of this app, but the account ID of the app's virtual account.

Request https://api.github.com/users/renovate[bot]

{
  "login": "renovate[bot]",
  "id": 29139614,
.....
}

The numbers in the "from" message in this patch are consistent.

From 80c9bee698498ff3c14c95f5ac76d7f2d9d755bc Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Fri, 16 Feb 2024 16:41:56 +0000
Subject: [PATCH] chore(deps): update dependency undici to v6.6.1 [security]
....
maboloshi commented 5 months ago

The name of the github app can be changed later, but it's always possible to get the latest github app's slug using the app id and private key. I that's one of the reasons I didn't want to hardcode Signed-off-by in my code.

So I hope that through this action, I can get the token and the slug of the app at the same time.

gr2m commented 5 months ago

Actually, 29139614 is not the installation ID of this app, but the account ID of the app's virtual account.

you are right, that's it, today I learned: https://api.github.com/user/29139614

Cheers!

Yeah we can add app-slug as output. I still want to add installation-id as another output but if you don't need it we can add it later.

Can you get the tests fixed? It might be as simple as updating the snapshots with npx ava tests/index.js -u

maboloshi commented 5 months ago

On my end, the snapshot file generated using npx ava tests/index.js has line breaks in the format \r\n instead of \n, and I'm guessing that after push the github action for test will still report an error.

Resolved Line Break Styles.

create-app-token-action-releaser[bot] commented 4 months ago

:tada: This PR is included in version 1.9.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: