Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 8 additions & 35 deletions .github/workflows/strands-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,46 +23,19 @@ on:
jobs:
authorization-check:
if: startsWith(github.event.comment.body, '/strands') || github.event_name == 'workflow_dispatch'
name: Check access
permissions: read-all
runs-on: ubuntu-latest
outputs:
approval-env: ${{ steps.collab-check.outputs.result || steps.auto-approve.outputs.result }}
approval-env: ${{ steps.auth.outputs.result }}
steps:
- name: Collaborator Check
if: github.event_name != 'workflow_dispatch'
uses: actions/github-script@v8
id: collab-check
- name: Check Authorization
id: auth
uses: strands-agents/devtools/authorization-check@main
with:
result-encoding: string
script: |
try {
const permissionResponse = await github.rest.repos.getCollaboratorPermissionLevel({
owner: context.repo.owner,
repo: context.repo.repo,
username: context.payload.comment.user.login,
});
const role_name = permissionResponse.data.role_name;
const hasWriteAccess = ['triage', 'write', 'admin'].includes(role_name);
if (!hasWriteAccess) {
console.log(`User ${context.payload.comment.user.login} does not have write access to the repository (permission: ${permission})`);
return "manual-approval"
} else {
console.log(`Verified ${context.payload.comment.user.login} has write access. Auto Approving strands command.`)
return "auto-approve"
}
} catch (error) {
console.log(`${context.payload.comment.user.login} does not have write access. Requiring Manual Approval to run strands command.`)
return "manual-approval"
}

- name: Auto-approve for workflow dispatch
if: github.event_name == 'workflow_dispatch'
id: auto-approve
uses: actions/github-script@v8
with:
result-encoding: string
script: |
return "auto-approve"
skip-check: ${{ github.event_name == 'workflow_dispatch' }}
username: ${{ github.event.comment.user.login || 'invalid' }}
allowed-roles: 'triage,write,admin'

setup-and-process:
needs: [authorization-check]
Expand Down
36 changes: 10 additions & 26 deletions .github/workflows/trigger-preview-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,24 @@ name: Trigger Preview Deployment
on:
pull_request_target:
branches: [main]
merge_group: # Run tests in merge queue
types: [checks_requested]

jobs:
authorization-check:
name: Check access
permissions: read-all
runs-on: ubuntu-latest
outputs:
approval-env: ${{ steps.collab-check.outputs.result }}
approval-env: ${{ steps.auth.outputs.result }}
steps:
- name: Collaborator Check
uses: actions/github-script@v8
id: collab-check
- name: Check Authorization
id: auth
uses: strands-agents/devtools/authorization-check@main
with:
result-encoding: string
script: |
try {
const permissionResponse = await github.rest.repos.getCollaboratorPermissionLevel({
owner: context.repo.owner,
repo: context.repo.repo,
username: context.payload.pull_request.user.login,
});
const permission = permissionResponse.data.permission;
const hasWriteAccess = ['write', 'admin'].includes(permission);

if (!hasWriteAccess) {
console.log(`User ${context.payload.pull_request.user.login} does not have write access to the repository (permission: ${permission})`);
return "manual-approval"
} else {
console.log(`Verified ${context.payload.pull_request.user.login} has write access. Auto approving documentation deployment.`)
return "auto-approve"
}
} catch (error) {
console.log(`${context.payload.pull_request.user.login} does not have write access. Requiring manual approval to deploy documentation.`)
return "manual-approval"
}
skip-check: ${{ github.event_name == 'merge_group' }}
username: ${{ github.event.pull_request.user.login || 'invalid' }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make sure to never add invalid to the repository :)

allowed-roles: 'triage,write,admin'

trigger-docs-deploy:
runs-on: ubuntu-latest
Expand Down