We are currently tightening our security policies on certain actions in Spacelift. One of our focus is to reach the plan phase of a proposed run only after an approval of a codeowner.
So far we succeeded testing adding a label on a stack that basically contains a list of GitHub teams based off of the actual CODEOWNERS, this way Spacelift on any action in the stack can access to the GitHub team that owns the stack and the code it tracks.
Then we created an approval policy that waits for an approval from the codeowners. Once a PR is created and thus a proposed run is triggered and starts, then evaluates something in the lines of:
requires_approval if { not creator_is_codeowner } ## Creator is a code owner if their GitHub teams overlap with codeowner_teams creator_is_codeowner if { some session_team in input.session.teams some codeowner_team_group in codeowner_teams session_team in codeowner_team_group } ## Auto-approve: creator is code owner approve if not requires_approval ## Approve: someone from the owning team reviewed in Spacelift approve if { count(input.reviews.current.rejections) == 0 requires_approval some review in input.reviews.current.approvals some session_team in review.session.teams some codeowner_team_group in codeowner_teams session_team in codeowner_team_group }TL;DR if the author of the PR is not a codeowner (i.e. doesn't belong to a github team the the stack is labeled with), then requires an approval of a codeowner.
The parts that work:
The approval policy is evaluated before the plan phase

The approval policy lets the run continue and finish only after a codeowner approval

The parts that we would like to have but are not supported by Spacelift (to the best of our knowledge)
At the PR creation event and evaluation of the approval policy this block is in the approval policy:
... "commit": { "author": "AUTHOR_USERNAME", "branch": "BRANCH_NAME", "created_at": 1785152807000000000, "exist_on_tracked_branch": false, "hash": "HASH", "message": "Test codeowners approval", "tag": "", "url": "https://github.com/ORG/REPO/commit/COMMIT_HASH" }, ... "creator_session": { "admin": "", "creator_ip": "", "idp_subject": "", "login": "", "machine": true, "name": "", "teams": [] } ...No way of getting author teams

Also if we want to read an event via a push policy, such as a comment like /spacelift approve I see that also no teams are available from the commentor

Please authenticate to join the conversation.
π In Review
π‘ Feature Requests
Policies
About 14 hours ago
Get notified by email when there are changes.
π In Review
π‘ Feature Requests
Policies
About 14 hours ago
Get notified by email when there are changes.