community icon indicating copy to clipboard operation
community copied to clipboard

ci: add workflow for team sync

Open BethGriggs opened this issue 5 months ago • 7 comments

Triggers a sync when a TEAMS yml file is updated.


Note that this would rely on GITHUB_TOKEN: ${{ secrets.GH_TEAM_SYNC_TOKEN }} being created with appropriate permission to manage teams. I couldn't find a token/app used elsewhere with these permissions - but, it might be good to have a fine-grained scope for this token anyway?

BethGriggs avatar Aug 07 '25 11:08 BethGriggs

Any updates on the token needed for this? 🙏🏻

BethGriggs avatar Oct 22 '25 13:10 BethGriggs

@BethGriggs did you verify that the current credentials don't work? I had a look at the token scopes and as far as I could find it's a classic token with org:write scope, which I think should be enough. Should we ship this and see if it works? 🤞

Rugvip avatar Nov 12 '25 21:11 Rugvip

Sorry, I am not sure I am following the last comment. Is the implication that secrets.GH_TEAM_SYNC_TOKEN already exists with the correct scope or is there another existing token I should use in the workflow (maybe secrets.GITHUB_TOKEN)?

Either way, the workflow is pretty minimal is it should good to ship, I think we just need to know which named secret it should use.

BethGriggs avatar Nov 13 '25 15:11 BethGriggs

Ah yes ofc, was assuming that this was using the existing secret for some reason but a separate one is better for sure. GH_TEAM_SYNC_TOKEN now exists in this repo with a more narrow scope.

Rugvip avatar Nov 17 '25 15:11 Rugvip

Ah, realized this very much won't work though since the service account doesn't have access to add and remove team members. Thinking we might need to use an app for this instead? 🤔 Not to happy having an org owner token in there either

Rugvip avatar Nov 17 '25 15:11 Rugvip

Hmm, do you know if that involve refactoring the script to use an app, as described in the GitHub docs - Authenticating as a GitHub app?

BethGriggs avatar Nov 18 '25 16:11 BethGriggs

Yep, as far as I can tell. I've created an app and installed it and added the following secrets to this repo with corresponding values:

  • BACKSTAGE_ORG_MANAGER_APPLICATION_ID
  • BACKSTAGE_ORG_MANAGER_INSTALLATION_ID
  • BACKSTAGE_ORG_MANAGER_PRIVATE_KEY

Here's another place where we set up auth in workflows using app credentials: https://github.com/backstage/actions/blob/b3c1841fd69e1658ac631afafd0fb140a2309024/lib/createAppClient.ts#L3

Rugvip avatar Nov 18 '25 21:11 Rugvip