Repository navigation
ci: replace the add-to-project PAT with a GitHub App token (#376) - #377
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
The migration requires live post-merge validation of the GitHub App’s credentials and organization-project write access for both issues and pull requests before removing the PAT secret.
No open issues 🎉
What changed in this PR
Replaces the add-to-project workflow’s personal access token with a short-lived GitHub App installation token, addressing #376.
Changes:
- Generates an App token scoped to organization projects write access.
- Pins both actions to commit SHAs and disables
GITHUB_TOKENpermissions. - Requires post-merge verification before deleting the old PAT secret.
| File | Description |
|---|---|
.github/workflows/integrations-add-to-project.yml |
Generates and uses the App token, pins actions, and sets permissions: {}. |
Review effort: Balanced
GITHUB_TOKEN cannot write to an organization project. Instead of a personal access token, create a short-lived GitHub App installation token, limited to organization projects. Read the project URL from the shared XTM_INTEGRATIONS_PROJECT_URL organization variable instead of the per-repository PROJECT_URL. Pin add-to-project to a commit SHA and drop the default GITHUB_TOKEN permissions, which the job does not use. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
715adc0 to
1ba12a0
Compare
Frédéric BASLER (Megafredo)
left a comment
There was a problem hiding this comment.
Thanks for your work!
These are just suggestions, nothing that would block the PR, but they also apply to your other two PRs:
OpenAEV-Platform/collectors#664
OpenAEV-Platform/injectors#493
| id: app-token | ||
| uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 | ||
| with: | ||
| app-id: ${{ vars.ADD_TO_PROJECT_APP_ID }} |
There was a problem hiding this comment.
Use client-id instead of app-id
The official actions/create-github-app-token documentation now recommends using the client-id input instead of app-id to identify the GitHub App.
The legacy app-id input is also accepted, but client-id is recommended.
However, using app-id is not currently an issue, as this input is still supported for backward compatibility. Nevertheless, since we are already making changes to this GitHub Action, it might be a good opportunity to anticipate this migration and align with the current recommendations ?
I don't have access to the GitHub App configuration, so I cannot verify whether our Client ID is available. If we decide to proceed with this migration, we should also remember to add a dedicated variable environment (e.g. ADD_TO_PROJECT_APP_CLIENT_ID ?) so that it can be used in the workflows across the respective repositories.
There was a problem hiding this comment.
Done: the workflow now uses client-id with a new ADD_TO_PROJECT_APP_CLIENT_ID variable, and the ADD_TO_PROJECT_APP_ID variable is removed. Thanks!
| app-id: ${{ vars.ADD_TO_PROJECT_APP_ID }} | ||
| private-key: ${{ secrets.ADD_TO_PROJECT_APP_PRIVATE_KEY }} | ||
| owner: FiligranHQ | ||
| permission-organization-projects: write |
There was a problem hiding this comment.
Explicitly specify the required permissions
One thing caught my attention while reading the actions/create-github-app-token
By default, the token inherits all of the installation's permissions.
We recommend to explicitly list the permissions that are required for a use case.
Since I don't have access to the GitHub App configuration, I cannot verify which permissions are currently granted to its installation.
Wouldn't it be worth explicitly restricting the token's permissions, even though the source repositories are public? This would help prevent the token from inheriting unnecessary write permissions for issues and pull requests, reducing the potential impact in case the token is compromised.
My suggestion would be to follow the GitHub recommendation and explicitly add the following permissions:
permission-issues: read
permission-pull-requests: readThere was a problem hiding this comment.
I believe the access is already restricted as permission-organization-projects: write makes the token request only that permission. Adding issues/pull-requests: read would widen it.
actions/create-github-app-token deprecates the app-id input in favor of client-id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Frédéric BASLER (Megafredo)
left a comment
There was a problem hiding this comment.
Thank you for these improvements; this works for me!
Proposed changes
ADD_TO_PROJECT_PATpersonal access token with a short-lived GitHub App installation token, created byactions/create-github-app-tokenand limited to organization projects (permission-organization-projects: write).XTM_INTEGRATIONS_PROJECT_URLorganization variable instead of the per-repositoryPROJECT_URLvariable.client-id):actions/create-github-app-tokendeprecatesapp-id.actions/add-to-projectto a commit SHA and setpermissions: {}: the job does not useGITHUB_TOKEN.Testing Instructions
ADD_TO_PROJECT_APP_CLIENT_IDvariable and theADD_TO_PROJECT_APP_PRIVATE_KEYsecret are already set on this repository.issuesandpull_request_targetrun the workflow from the default branch, so this PR cannot test itself: after the merge, open a test issue and check that the workflow succeeds and the issue lands on the project.ADD_TO_PROJECT_PATsecret and thePROJECT_URLvariable.Related issues
Checklist
Further comments
🤖 Generated with Claude Code