Skip to content

Commit 66d14e6

Browse files
committed
build and push agents workflow
1 parent d44c2f2 commit 66d14e6

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

.github/workflows/build-and-push-tutorial-agent.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,31 @@ permissions:
2424
packages: write
2525

2626
jobs:
27+
check-permissions:
28+
if: ${{ github.event_name == 'workflow_dispatch' }}
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Check if user is maintainer
32+
uses: actions/github-script@v7
33+
with:
34+
script: |
35+
const { data: permission } = await github.rest.repos.getCollaboratorPermissionLevel({
36+
owner: context.repo.owner,
37+
repo: context.repo.repo,
38+
username: context.actor
39+
});
40+
41+
console.log(`User ${context.actor} has permission level: ${permission.permission}`);
42+
43+
const allowedRoles = ['admin', 'maintain'];
44+
if (!allowedRoles.includes(permission.permission)) {
45+
throw new Error(`❌ User ${context.actor} does not have sufficient permissions. Required: ${allowedRoles.join(', ')}. Current: ${permission.permission}`);
46+
}
47+
2748
find-agents:
2849
runs-on: ubuntu-latest
50+
needs: [check-permissions]
51+
if: ${{ !cancelled() && !failure() }}
2952
outputs:
3053
agents: ${{ steps.get-agents.outputs.agents }}
3154
has_agents: ${{ steps.get-agents.outputs.has_agents }}
@@ -157,7 +180,7 @@ jobs:
157180
echo "🚀 Building and pushing agent: ${{ matrix.agent_path }}"
158181
else
159182
SHOULD_PUSH=false
160-
VERSION_TAG="pr-${{ github.event.number }}"
183+
VERSION_TAG="${{ github.commit.sha }}"
161184
echo "🔍 Validating build for agent: ${{ matrix.agent_path }}"
162185
fi
163186

0 commit comments

Comments
 (0)